Python urllib2 Tor 514身份验证必需
发布时间:2020-12-20 13:25:53 所属栏目:Python 来源:网络整理
导读:我试图使用Tor与 python和urllib2,并被卡住了.下列 print opener.open('http://check.torproject.org/').read() 和 telnet 127.0.0.1 9051 给我以下错误: 514 Authentication Required. 这是我想要使用的代码:但是我在urllib2.urlopen调用上收到了相同的51
我试图使用Tor与
python和urllib2,并被卡住了.下列
print opener.open('http://check.torproject.org/').read() 和 telnet 127.0.0.1 9051 给我以下错误: 514 Authentication Required. 这是我想要使用的代码:但是我在urllib2.urlopen调用上收到了相同的514 Authentication Error. import urllib2 # using TOR ! proxy_support = urllib2.ProxyHandler({"http" : "127.0.0.1:9051"} ) opener = urllib2.build_opener(proxy_support) urllib2.install_opener(opener) # every urlopen connection will then use the TOR proxy like this one : urllib2.urlopen('http://www.google.com').read() 有关为何发生这种情况的任何建议? Tor Vidalia浏览器 – >设置 – >高级:身份验证设置为“随机生成” 我正在使用Python 2.65 urllib2 Tor 解决方法
Google搜索
suggests(和Tor手册
confirms)表明9051是Tor的默认控制端口.默认情况下,实际代理在端口9050上运行,这是您需要使用的代理.但是,如果没有额外配置,Vidalia不会使用默认端口.
另一个问题是urllib2默认无法使用SOCKS代理.有关可能的解决方案,请参阅这些two questions. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |