import asyncio import aiohttp from aiosocksy.connector import ProxyConnector, ProxyClientRequest async def fetch(url): connector = ProxyConnector() socks = 'socks5://127.0.0.1:12377' async with aiohttp.ClientSession(connector=connector, request_class=ProxyClientRequest) as session: async with session.get(url, proxy=socks) as response: print(await response.text()) loop = asyncio.get_event_loop() loop.run_until_complete(fetch('https://www.google.com'))