我有 5,00,000 个网址。并希望获得每个异步的响应。
import aiohttp
import asyncio
@asyncio.coroutine
def worker(url):
response = yield from aiohttp.request('GET', url, connector=aiohttp.TCPConnector(share_cookies=True, verify_ssl=False))
body = yield from response.read_and_close()
print(url)
def main():
url_list = [] # lacs of urls, extracting from a file
loop = asyncio.get_event_loop()
loop.run_until_complete(asyncio.wait([worker(u) for u in url_list]))
main()
我一次想要 200 个连接(并发 200),不超过这个,因为
当我为 50 个 url 运行该程序时,它工作正常,即,url_list[:50]
但如果我通过整个列表,我会收到此错误
aiohttp.errors.ClientOSError: Cannot connect to host www.example.com:443 ssl:True Future/Task exception was never retrieved future: Task()
可能是频率太多,服务器在限制后拒绝响应?