【问题标题】:Making requests through tor, requests.exceptions.ConnectionError Errno 61: Connection Refused通过 tor 发出请求,requests.exceptions.ConnectionError Errno 61: Connection Refused
【发布时间】:2018-12-06 21:56:22
【问题描述】:

我正在尝试在连接到 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()

【问题讨论】:

    标签: python python-3.x python-requests tor


    【解决方案1】:

    错误是Max retries exceeded with url:,所以可能是从tor出口节点ip发出的请求太多。尝试使用新的 Tor 身份进行操作,看看是否可行。

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

    【讨论】:

      猜你喜欢
      • 2023-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-26
      • 2019-10-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多