Trying to get Tor to work with Python, but keep getting connection refused.

I tried to get Tor to work with Python, but I hit a brick wall. I just can't get any of the examples to work. Here is one of the https://stackoverflow.com/a/312616/

import urllib2
proxy  = urllib2.ProxyHandler({'http':'127.0.0.1:8118'})
opener = urllib2.build_opener(proxy)
print opener.open('http://check.torproject.org/').read()

I installed Tor and it works great when viewing Aurora. However, by running this python script, I get

Traceback (most recent call last):
File "/home/x/Tor.py", line 4, in <module>
  print opener.open('http://check.torproject.org/').read()
File "/usr/lib/python2.6/urllib2.py", line 391, in open
  response = self._open(req, data)
File "/usr/lib/python2.6/urllib2.py", line 409, in _open
  '_open', req)
File "/usr/lib/python2.6/urllib2.py", line 369, in _call_chain
  result = func(*args)
File "/usr/lib/python2.6/urllib2.py", line 1161, in http_open
  return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib/python2.6/urllib2.py", line 1136, in do_open
  raise URLError(err)
urllib2.URLError: <urlopen error [Errno 111] Connection refused>

I searched on the internet but could not find people with simiair problems. Did I miss something completely obvious ?!

+5
source share
3 answers

, !

Ubuntu, TOR ( ) Vidalia . , vidalia .

TorCtl python, TOR, , !

, , urllib2, Loko, .

- , !

0

Tor acts as a Socks5 proxy. You need to configure your script with this in mind. Google "socks.py"

0
source

All Articles