1

I am looking how to bypass pass proxy using tor and torctl, I looked on various steps and wrote this script in python.

After starting tor, ideally this should work

proxy_support = urllib2.ProxyHandler({"http" : "127.0.0.1:8118"} )
opener = urllib2.build_opener(proxy_support)
urllib2.install_opener(opener)
#urllib2.urlopen('http://www.google.fr')
data = json.load(urllib2.urlopen("https://www.google.co.in/trends/hottrends/hotItems?geo=IN&mob=0&hvsm=0"))

which again gives this message :

File "/usr/lib/python2.7/urllib2.py", line 528, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 503: Service Unavailable

I have already started tor and enabled control port using

tor --controlport 9051

after using tor as tor as a SOCKS proxy.

tor SOCKSPort 1080

python:

>>> import urllib2
>>> proxy_support = urllib2.ProxyHandler({"http" : "127.0.0.1:1080"})
>>> opener = urllib2.build_opener(proxy_support)
>>> urllib2.install_opener(opener)
>>> import json 
>>> data = json.load(urllib2.urlopen("https://www.google.co.in/trends/hottrends/hotItems?geo=IN&mob=0&hvsm=0"))

which again gives same error message.

Is there any way to get rid of this?

0

Tor creates a SOCKS proxy. You're using an HTTP proxy which is not the same proxy type. You'll need to configured urllib2 to use a SOCKS proxy instead. Alternatively, you could use Privoxy to host an HTTP proxy on port 1080 and then tunnels to the SOCKS proxy that Tor is running.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.