httplib and Proxy

Rolf Wester wester at
Fri Nov 21 09:52:14 CET 2003

Rolf Wester wrote:
> Hi,
> I want to fetch some web-pages via http. I know how to do this without a 
> proxy server in between but unfortunately we can only access the 
> internet via a proxy. I would be very appriciative if anybody could tell 
> me how to do this.
> Thanks in advance
> Rolf Wester
> P.S.: I would not mind to use sockets directly

thank you all for your help. I tried urllib, httplib and sockets.

With urllib:

f = urllib.urlopen("")

I get:

invalid proxy for http: ''

httplib works:

conn = httplib.HTTPConnection("", 81)
conn.request("GET", "")
r = conn.getresponse()
print r.status, r.reason
print r.msg
while 1:
     data =
     if len(data) < 1024: break
     print data

and so do sockets:

HOST = ''
PORT = 81
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
s.send('GET HTTP/1.1\r\nAccept: 
while 1:
     data = s.recv(1024)
     print data
     if len(data) < 1024: break

Thanks again

Rolf Wester

More information about the Python-list mailing list