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

懵懂的女人 提交于 2019-12-11 16:12:28

问题


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


回答1:


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


来源:https://stackoverflow.com/questions/45511728/how-can-i-use-socks4-and-socks5-proxies-with-aiohttp-clientsession

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!