我目前有一个代码使用多线程和urllib2来模糊Web服务器(GET和POST),但问题是每个线程都在等待请求的响应。
import urllib,urllib2
from threading import Thread
def open_website(opener):
while True:
formdata ={"udsan":"fdsf",
"width":"1200",
"height":"1920",
"param":"32",
"rememberUn":"on"}
data_encoded = urllib.urlencode(formdata)
response = opener.open("https://example.com/", data_encoded)
opener = urllib2.build_opener()
opener.addheaders=[("Connection"," keep-alive"),
("Cache-Control"," max-age=0"),
("Accept"," text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"),
("Accept-Language"," en-US,en;q=0.8,es;q=0.6")]
THREADS=40
for i in range(THREADS):
t=Thread(target=open_website, args=[opener])
t.start()
我可以这样做我只是发送请求和线程忘记响应并执行下一个请求吗?
越快越好。
谢谢。