python - Tor doesn't work with urllib2 -


I am trying to use Tor for anonymous access through privoxy as a proxy using urllib2 .

System Info: Ubuntu 14.04, Recently upgraded to the dist-upgrade from 13.10.

This is a piece of code that I am using for testing purposes:

  import urllib2 def req (url): proxy_support = urllib2.ProxyHandler ({" Http ":" 127.0.0.1:8118 "} Opener = urllib2.build_opener (proxy_support) opener.addheaders = [('user-agent', 'mozilla / 5.0']] return opener .open (url) .read ( ) Print Rake ('https://check.torproject.org')   

One page above Sorry, but for you my configuration:

/ etc / tor / torrc

   

code> control port 9051 # # If enabled, be sure to enable one of these ## authentication methods to prevent attackers from accessing it. #HashedControlPassword 16: 872860B76832A77D60CA2BB8C1A7042072093276A3D701AD684053EC4C HashedControlPassword16: B3B0BA631D41D6FE601488FC7A9A2E80AB7815580C1C78F2865F30F63B

/ etc / privoxy / config

  Forward SOCKS5 / Local Host: 9050 .   

$ sudo netstat -ntap | grep tor Output:

  tcp 0 127.0.0.1:9050 0.0.0.0:* LISTEN 1045 / TRP 0 127.0.0.1:9051 0.0.0.0:* LISTEN 1045 / TRCP 10.0.0.94 Statement 6736 85.17.190.83:9002 Installed 1045 / TRP 0 10.0.0.94:60558 50.7.110.118:9001 Installed 1045 / TRP 0 10.0.0.94:43206 62.210.236.135:443 Installed 1045 / hour < / Code>  

$ sudo netstat -ntap | grep privoxy Output:

  tcp 0 127.0.0.1:8118 0.0.0.0:* LISTEN 887 / privoxy   

And yet, All requests received with my real server

Edit:

The code below, which is using the requested library, is the same Returns the output:

  Import request def rik (URL): Proxy = {"http:": "http://127.0.0.1:8118"} Get the return requests. Use (URL, Proxy / Proxy) .text print rake ('http://check.torproject.org')   

Tor log does not indicate any problem: 22 April 15: 44: 34.000 [Notices] 100% Bootstrap: Completed April 22 15: 45: 03.000 [Notice] Signaling TERM Holding, Clearing Out 22 Apr 16: 00: 57.000 [Information] Tor 0.2.4.20 (GIT-0D50B 03673670 D6) Opening the log file 22 Apr 16: 00: 57.000 [Notice] GEOP IPv4 Parsing File / User / Share / Tar / GOIP April 22 16: 00: 57.000 [Notice] Jiioopi IPv6 file / usr / share / Tark / Jioaipi 6 parsing April 22, 16: 00: 57.000 [Warning] OpenSSL version header does not match the version running by us. If you have a weird crash, then why may April 22 16: 00: 58.000 [NOTICE] 80% Bootstrap: Compiled with 1000105F: OpenSSL 1.0.1a 11 February 2013; YY $ 22 Apr 16: 00: 58.000 [Notice] We now have enough directory information to make the circuit. April 22 16: 00: 59.000 [Notices] 85% Bootstrap: Finishing the handshake with the first hop. 22 Apr 16: 00: 59.000 [Notices] 90% Bootstrap: Installation of Tor circuit. : 00,000 [Notice] Tor successfully opened a circuit. It seems that the customer's functionality is working. 22 Apr 16: 01: 00.000 [Notice] 100% Bootstrap: Full.

Maybe related.

In short, you are using a code 127.0.0.1:8118 , and a protocol URL as your protocol, but instead of the protocol https < / Code> should be.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -