ขณะนี้ฉันมีรายชื่อชื่อผู้ใช้ 80 ชื่อและสคริปต์ของฉันจะตรวจสอบว่ามีชื่อผู้ใช้แต่ละชื่อหรือไม่ อย่างไรก็ตาม มันใช้เวลานานกว่าที่ฉันชอบนิดหน่อย ดังนั้นฉันจึงสงสัยว่ามีอะไรที่ฉันสามารถทำได้เพื่อเร่งความเร็วในการตรวจสอบว่าชื่อผู้ใช้แต่ละชื่อมีอยู่แล้วหรือไม่
# ------------------------------
# Mass Kik Username Checker
# Script Made by: Ski
# ------------------------------
import requests, threading
def check(username):
try:
req = requests.get("http://kik.me/"+username, allow_redirects=False).status_code
if req == 302:
return False
if req == 200:
return True
except Exception as e:
print e
exit()
def _loadList(filename):
item_list = []
for item in str(open(filename, "r").read()).split("\n"):
item_list.append(item)
return item_list
def _thread(items):
global _usernames
for username in _usernames[items[0]:items[1]]:
exists = check(username)
if exists:
print username+" exists\n"
if not exists:
print username+" doesn't exist\n"
if __name__ == '__main__':
_usernames = _loadList("usernames.txt")
thread1 = threading.Thread(target=_thread, args=([0, 20], )).start()
thread2 = threading.Thread(target=_thread, args=([20, 40], )).start()
thread3 = threading.Thread(target=_thread, args=([40, 60], )).start()
thread4 = threading.Thread(target=_thread, args=([60, 80], )).start()
profile
และcProfile
cProfile
เป็นที่ต้องการ - person X-Mann   schedule 18.10.2015