簡體   English   中英

無法通過連接拒絕錯誤發出 python 請求:[WinError 10061]

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

我正在嘗試使用 python 請求通過 tor 發出請求,但出現錯誤“ConnectionRefusedError: [WinError 10061] 由於目標機器主動拒絕它,因此無法建立連接”。

這是我正在使用的代碼:

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,它奏效了!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM