import HackRequests
def _callback(r:HackRequests.response):
# 从回调函数取出结果,参数r是response结果
print(r.text())
threadpool = HackRequests.threadpool(threadnum=10,callback=_callback,timeout=10)
raw = '''
GET / HTTP/1.1
Host: x.hacking8.com
Connection: Keep-Alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
'''
for i in range(20):
threadpool.httpraw(raw)
threadpool.run()
返回结果
None httpraw() takes 2 positional arguments but 5 were given
None httpraw() takes 2 positional arguments but 5 were given
None httpraw() takes 2 positional arguments but 5 were given
None httpraw() takes 2 positional arguments but 5 were given
None httpraw() takes 2 positional arguments but 5 were given
None httpraw() takes 2 positional arguments but 5 were given
None httpraw() takes 2 positional arguments but 5 were given
None httpraw() takes 2 positional arguments but 5 were given
None httpraw() takes 2 positional arguments but 5 were given
None httpraw() takes 2 positional arguments but 5 were given
None httpraw() takes 2 positional arguments but 5 were given
None httpraw() takes 2 positional arguments but 5 were given
None httpraw() takes 2 positional arguments but 5 were given
None httpraw() takes 2 positional arguments but 5 were given
None httpraw() takes 2 positional arguments but 5 were given
None httpraw() takes 2 positional arguments but 5 were given
None httpraw() takes 2 positional arguments but 5 were given
None httpraw() takes 2 positional arguments but 5 were given
None httpraw() takes 2 positional arguments but 5 were given
None httpraw() takes 2 positional arguments but 5 were given
返回结果