Using https proxy with aiohttp

760 Views Asked by At

I need to fetch data from an https url. I've learned that aiohttp doesn't support https proxy. Is there a way to overcome this. I've read lots of previous replies but couldn't find anything.

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()

I have my proxies like this

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

There are 0 best solutions below