def crawtest(step, proxy, urlquery, isproxy):
#global log1,log2
threadname = "??" + threading.currentThread().getName()
headers = {"Proxy-Authorization":"SDU0Ujg4MTI4N0UxN1I2RDo4QzFERjYyNUIwMzI4ODJD"}
http_ok = 0
http_notok = 0
for i in range(0,step):
try:
if isproxy == 1:
craw_result = requests.get(urlquery[i]["url"],proxies=proxy,headers=headers,verify=False)
else:
craw_result = requests.get(urlquery[i]["url"],headers=headers,verify=False)
if craw_result.status_code==200:
http_ok = http_ok + 1
#log1.write(threadname+"http_ok\n")
else:
http_notok = http_notok + 1
#log1.write(threadname+"http_error\n")
#request.get??
except Exception as e:
print("sigleTest???????????"+threadname+str(e)+'\n')
#log2.write("sigleTest???????????"+threadname+str(e)+'\n')
break
pass
#log1.write("the thread is over"+threadname+'\n'+'len(http_ok)='+str(http_ok)+'\t'+'len(http_notok)='+str(http_notok)+'\n')
评论列表
文章目录