4
失败的Tor检查通过StackOverflow上的otherquestions看完后,我得到的Python代码片段,是能够通过Tor的代理发出请求:使用Python的urllib2发起请求
import urllib2
proxy = urllib2.ProxyHandler({'http':'127.0.0.1:8118'})
opener = urllib2.build_opener(proxy)
print opener.open('https://check.torproject.org/').read()
由于Tor的正常工作在使用TorButton的Firefox中,我预计它可以在Python中正常工作。不幸的是,收录在HTML的混乱中:Sorry. You are not using Tor
。我不确定为什么会出现这种情况,或者如何让Tor正常使用urllib2
。
太棒了!我甚至没有考虑过这个。非常感谢你。 – 2010-01-15 23:49:08