Running python script with TOR

Hello Guys! At first I want to assure that there is similar topics but there is no accepted answer or clear response. So I want to combine them and ask again. I have following script: import urllib2 proxy = urllib2.ProxyHandler({"http":""}) opener = urllib2.build_opener(proxy) print("").read()) I want to run it anonymously, using with tor for example. But it gives this error: Traceback (most recent call last): File "", line 5, in print("").read()) File "/usr/lib/python2.7/", line 400, in open response = meth(req, response) File "/usr/lib/python2.7/", line 513, in http_response 'http', request, response, code, msg, hdrs) File "/usr/lib/python2.7/", line 438, in error return self._call_chain(*args) File "/usr/lib/python2.7/", line 372, in _call_chain result = func(*args) File "/usr/lib/python2.7/", line 521, in http_error_default raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) urllib2.HTTPError: HTTP Error 501: Tor is not an HTTP Proxy I have found following answers in stackoverflow: proxy_support = urllib2.ProxyHandler({"http" : ""}) opener = urllib2.build_opener(proxy_support) opener.addheaders = [('User-agent', 'Mozilla/5.0')] print'').read() And also this comment to this topic: It may be worthwhile for people reading this thread to know that port 8118 is actually Privoxy's port, not Tor. Tor is a strictly SOCKS-only proxy (port 9050) so it rejects all non-SOCKS traffic (e.g. HTTP). To handle non-SOCKS traffic, you would need to use Privoxy (port 8118) or Polipo (port 8123) to translate the traffic into SOCKS so Tor would accept. Privoxy is better for privacy and Polipo is better for performance because it does caching. Can anyone explain how to execute my script anonymously?
possible duplicate of Tor with Python?

以上就是Running python script with TOR的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » WebStorm

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准