我有一个发送GET请求的代码部分:
proxy_auth = aiohttp.BasicAuth('proxy-username', 'proxy-password')
async with session.get('https://google.com', headers=headers, proxy='http://proxy_url.com', proxy_auth=proxy_auth) as response:
html = await response.text()
问题是,当我尝试获取https
网站时,它会返回以下异常:
ClientConnectorError: Cannot connect to host google.com:443 ssl:default [The parameter is incorrect]
只有当网站由https
提供时才会引发此异常,因为http
没有异常。
代理是https
,但是aiohttp只接受http
代理,但是我知道有一些技巧可以让它工作
我找到了解决那个问题的办法。发生这种情况是因为
aiohttp
库本身,所以我们需要将Event Policy Loop
更改为asyncio.WindowsSelectorEventLoopPolicy()
就像这样:
相关问题 更多 >
编程相关推荐