0

我需要从 https url 获取数据。我了解到 aiohttp 不支持 https 代理。有没有办法克服这个。我已经阅读了很多以前的回复,但找不到任何东西。

async def fetch(url, session):
    async with session.get(url, proxy=proxies['https']) as response:
        res_dic = await response.json()
        status = response.status

loop = asyncio.get_event_loop()
with ClientSession(headers=headers) as session:
    loop.run_until_complete(*[asyncio.ensure_future(fetch(url, session)) for url in urls])
loop.close()

我有这样的代理

proxies = {
    "https": "https://{}:{}@{}".format(username, password, proxy_url),
    "http": "http://{}:{}@{}".format(username, password, proxy_url)
}
4

0 回答 0