Unable to make python requests over tor ConnectionRefusedError: [WinError 10061]

Unable to make python requests over tor ConnectionRefusedError: [WinError 10061]

我正在尝试使用 python 请求通过 tor 发出请求,但我收到错误 "ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it"。

这是我使用的代码:

import requests

def get_tor_session():
    session = requests.session()
    # Tor uses the 9050 port as the default socks port
    session.proxies = {'http':  'socks5://127.0.0.1:9050',
                       'https': 'socks5://127.0.0.1:9050'}
    return session

# Make a request through the Tor connection
# IP visible through Tor
session = get_tor_session()
print(session.get("http://httpbin.org/ip").text)
# Above should print an IP different than your public IP

# Following prints your normal public IP
print(requests.get("http://httpbin.org/ip").text)

我试过禁用防火墙等,但似乎无法理解问题所在,如有任何帮助,我们将不胜感激。我正在使用 python 3.7 windows 10.

感谢大家的帮助,是的,正如评论中已经提到的,代理出了点问题。

我改了:

session.proxies = {'http':  'socks5://127.0.0.1:9050',
                   'https': 'socks5://127.0.0.1:9050'}

收件人:

session.proxies = {'http':  'socks5://127.0.0.1:9150',
                   'https': 'socks5://127.0.0.1:9150'}

90 到 91 的地址有效!