简体   繁体   English

urllib2中的polipo与Tor .exit

[英]Tor .exit with polipo from urllib2

I am trying to use Tor with urllib2 and polipo. 我试图使用Tor用的urllib2和Polipo即可。 What I need is a way to switch to specific exit nodes while program is running. 我需要的是一种在程序运行时切换到特定出口节点的方法。 I have set 'AllowDotExit 1' in /etc/tor/torrc and was trying the following approach: 我在/ etc / tor / torrc中设置了“ AllowDotExit 1”,并尝试使用以下方法:

import urllib2

proxy = '127.0.0.1'
port = '8118'

url='http://ifconfig.me.651d7ace80e0b53e6c05eb4db2491264f049df66.exit'

proxyurl = '%s:%s' % (proxy, port)
proxyhandler = urllib2.ProxyHandler({'http': proxyurl})
opener = urllib2.build_opener(proxyhandler)

page = opener.open(url)
print 'Page opened.'
print page.read()

But what I am getting is: 但是我得到的是:

    :!/usr/bin/env python tortest.py
Traceback (most recent call last):
  File "tortest.py", line 18, in <module>
    page = opener.open(url, timeout=20)
  File "/usr/lib/python2.7/urllib2.py", line 406, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 519, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 444, in error
    return self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 527, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 504: Connect to ifconfig.me.651d7ace80e0b53e6c05eb4db2491264f049df66.exit:80 failed: General SOCKS server failure 

Could anyone help me with that? 有人可以帮我吗?

General SOCKS server failure could be anything. General SOCKS server failure可能是什么。 For example, your TOR node might not know how to reach the specified exit node. 例如,您的TOR节点可能不知道如何到达指定的出口节点。 This happens a lot. 这经常发生。 The exit may be listed on one of the status pages, but still be unreachable from your tor node. 该出口可能列在状态页面之一上,但是仍然无法从您的tor节点到达。 Try a different exit, or retry it later. 尝试使用其他出口,或稍后重试。 Often when you request a particular exit node, it takes some minutes to establish a link through the network. 通常,当您请求特定的出口节点时,需要花费几分钟的时间才能通过网络建立链接。

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

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