简体   繁体   中英

How can i use SOCKS4 and SOCKS5 proxies with aiohttp ClientSession?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM