Tor 求助

178 天前
 xiaohundun

为什么 https://httpbin.org/get 这个地址我在 tor 中可以匿名访问但是在 python 里使用 tor 的 socks 代理的时候就不行呢?

代码:


def switch_proxy():
    """
    切换 Tor 代理地址
    :return: NULL
    """
    with Controller.from_port(port=9151) as controller:
        controller.authenticate()
        if controller.is_newnym_available():
            print("hi")
            controller.signal(Signal.NEWNYM)  # type: ignore


for i in range(10):
    switch_proxy()
    print(1)
    proxies = {"http": "socks5://127.0.0.1:9150", "https": "socks5://127.0.0.1:9150"}
    output = requests.get("https://httpbin.org/get", proxies=proxies)
    print(2)
    print(json.loads(output.content))

819 次点击
所在节点    Python
3 条回复
xiaohundun
178 天前
求助求助😭
hanssx
178 天前
pip install requests[socks] 试试
xiaohundun
178 天前
@hanssx 有这个包,问题不在程序,是 tor 那里的出口节点访问目标站失败了,感觉是不是被 block 了

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/992689

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX