python怎么访问网站,如何使用python aiohttp连接到.onion网站?

本文档描述了使用Python aiohttp库尝试访问.onion网站时遇到的错误,具体为ClientConnectorError。问题在于DNS解析。通过设置`rdns=True`在SocksConnector中启用远程DNS解析,可以成功解决此问题,使得代码能够像requests库那样正常工作。
摘要由CSDN通过智能技术生成

I am trying to connect to a .onion site using python. I have tor running on port 9050 and I am getting the following error:

Traceback (most recent call last):

File "/Users/jane/code/test/test.py", line 15, in main

res = await fetch(session, id)

File "/Users/jane/code/test/test.py", line 9, in fetch

async with session.get(url) as res:

File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 1005, in __aenter__

self._resp = await self._coro

File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 476, in _request

timeout=real_timeout

File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 522, in connect

proto = await self._create_connection(req, traces, timeout)

File "/usr/local/lib/python3.7/site-pa

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值