python - bypass proxy using tor and torctl -


i looking how bypass pass proxy using tor , torctl, looked on various steps , wrote script in python.

after starting tor, ideally 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 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 started tor , enabled control port using

tor --controlport 9051 

do need make other change?

edit treaceback after change per new answer of running tor on 1080 port

>>> 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")) ('216.58.220.3', 443) traceback (most recent call last):   file "<stdin>", line 1, in <module>   file "/usr/lib/python2.7/urllib2.py", line 127, in urlopen     return _opener.open(url, data, timeout)   file "/usr/lib/python2.7/urllib2.py", line 407, in open     response = meth(req, response)   file "/usr/lib/python2.7/urllib2.py", line 520, in http_response     'http', request, response, code, msg, hdrs)   file "/usr/lib/python2.7/urllib2.py", line 445, in error     return self._call_chain(*args)   file "/usr/lib/python2.7/urllib2.py", line 379, in _call_chain     result = func(*args)   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 

you can use tor socks proxy.

start tor with:

tor socksport 1080 

and use socks 5 proxy @ 127.0.0.1:1080.

also check question on how use socks proxy urllib2.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -