简体   繁体   English

Python urllib2 Tor 514身份验证必需

[英]Python urllib2 Tor 514 Authentication Required

I am trying to use Tor with python and urllib2 and am stuck. 我试图使用Tor与python和urllib2,并被卡住了。 The following 下列

print opener.open('http://check.torproject.org/').read()

And

telnet 127.0.0.1 9051

gives me the following error: 给我以下错误:

514 Authentication Required.

Here is the code I want to use: But I receive the same 514 Authentication Error on the urllib2.urlopen call. 这是我想要使用的代码:但是我在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()

Any suggestions on why this is occurring? 有关为何发生这种情况的任何建议?

The Tor Vidalia browser -> settings -> Advanced: Authentication set to 'Randomly Generate' Tor Vidalia浏览器 - >设置 - >高级:身份验证设置为'随机生成'

I am Using Python 2.65 urllib2 Tor 我正在使用Python 2.65 urllib2 Tor

Google search suggests (and Tor manual confirms ) that 9051 is Tor's default control port. 谷歌搜索建议 (和Tor手册确认 )9051是Tor的默认控制端口。 Actual proxy is running on port 9050 by default, which is the one you need to use. 默认情况下,实际代理在端口9050上运行,这是您需要使用的代理。 However, Vidalia does not use the default ports without extra configuration. 但是,如果没有额外配置,Vidalia不会使用默认端口。

The other problem is that urllib2 is by default unable to work with SOCKS proxies. 另一个问题是urllib2默认无法使用SOCKS代理。 For possible solutions see these two questions . 对于可能的解决方案,请看这两个

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

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