如何在aiohttp ClientSession中使用SOCKS4和SOCKS5代理? [英] How can i use SOCKS4 and SOCKS5 proxies with aiohttp ClientSession?

查看:315
本文介绍了如何在aiohttp ClientSession中使用SOCKS4和SOCKS5代理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何在aiohttp ClientSession中使用SOCKS4和SOCKS5代理?需要一些小例子。谢谢!

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

推荐答案

您尝试过aiosocks吗?

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

这篇关于如何在aiohttp ClientSession中使用SOCKS4和SOCKS5代理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆