How can i use SOCKS4 and SOCKS5 proxies with aioht

2019-08-22 02:02发布

How can i use SOCKS4 and SOCKS5 proxies with aiohttp ClientSession? Need some small example. Thanks!

1条回答
聊天终结者
2楼-- · 2019-08-22 02:36

Have you tried aiosocks ?

import asyncio
import aiosocks
from aiosocks.connector import SocksConnector

conn = SocksConnector(proxy=aiosocks.Socks5Addr(PROXY_ADDRESS, PROXY_PORT), proxy_auth=None, remote_resolve=True)
session = aiohttp.ClientSession(connector=conn)
async with session.get('http://python.org') as resp:
    assert resp.status == 200
查看更多
登录 后发表回答