Python urllib2 Tor 514 Authentication Required

I am trying to use Tor with python and urllib2 and am stuck. Following

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

and

 telnet 127.0.0.1 9051 

gives the following error:

 514 Authentication Required. 

Here is the code I want to use: but I get the same 514 authentication error on urllib2.urlopen call.

 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 happening?

Tor Vidalia Browser โ†’ Settings โ†’ Advanced: Authentication is set to โ€œCustom Createโ€

I am using Python 2.65 urllib2 Tor

+4
source share
1 answer

A Google search suggests (and the Tor manual confirms ) that 9051 is Tor's default management port. The actual proxy server works by default on port 9050, which you need. However, Vidalia does not use default ports without additional configuration.

Another problem is that urllib2 cannot work with SOCKS proxy by default. For possible solutions see these two questions .

+1
source

Source: https://habr.com/ru/post/1386901/


All Articles