繁体   English   中英

通过tor发出请求,requests.exceptions.ConnectionError Errno 61:连接被拒绝

[英]Making requests through tor, requests.exceptions.ConnectionError Errno 61: Connection Refused

连接到tor时,我试图向whatsmyip网站提出一个简单的请求,但是无论我如何尝试,我仍然会遇到此错误:

requests.exceptions.ConnectionError: SOCKSHTTPSConnectionPool(host='httpbin.org', port=443): Max retries exceeded with url: /get (Caused by NewConnectionError('<urllib3.contrib.socks.SOCKSHTTPSConnection object at 0x1018a7438>: Failed to establish a new connection: [Errno 61] Connection refused'))

我在这里查看了很多类似问题的文章,但似乎找不到有效的解决方案。

这是当前的代码,但是我尝试了多种方法,并且每次都遇到相同的错误:

import requests

def main():
    proxies = {
            'http': 'socks5h://127.0.0.1:9050',
            'https': 'socks5h://127.0.0.1:9050'
    }
    r = requests.get('https://httpbin.org/get', proxies=proxies)
    print(r.text)


if __name__ == '__main__':
    main()

好吧,该错误表明Max retries exceeded with url:Max retries exceeded with url: ,因此可能是来自tor出口节点ip的请求过多。 尝试使用新的Tor身份执行此操作,然后查看是否可行。

如果您愿意,可以捕获异常并将其放入循环中以尝试每隔几秒钟,但这可能导致该IP地址被服务器拒绝的时间更长。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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