views:

116

answers:

2

I wrote this code:

import urllib
proxies = {'http': 'http://112.65.135.54:8080/'}
opener = urllib.FancyURLopener(proxies)
r = opener.open("http://www.python.org/")
print r.read()

and when I execute it this program works fine, and send for me source code of python.org But when i use this:

import urllib
proxies = {'http': 'http://80.176.245.196:1080/'}
opener = urllib.FancyURLopener(proxies)
r = opener.open("http://www.python.org/")
print r.read()

this program does not send me the source code of python.org What am I going to do?

+1  A: 

Presumably, the first IP address and port points to a working proxy, while the second set does not (they're on private IPs so of course nobody else can check). So, speak with whoever handles your local network, and get the exact specs for IP and port of the HTTP proxy you're supposed to use!

Edit: aargh, the question had been edited to "mask" the IPs (now they're back and they're definitely not on private networks!) -- so the answer was based on that. Anyway, no need for digging now, as the OP has already discovered that one is a socks proxy, not an http proxy, and so of course can't be treated as the latter;-).

Alex Martelli
+1  A: 

hehe :d i find the answer i must use "socks" instead of "http" : import urllib proxies = {'socks': 'http://80.176.245.196:1080/'} opener = urllib.FancyURLopener(proxies) r = opener.open("http://www.python.org/") print r.read()

this code works fine

Emma