How to get web page through a proxy server?

PythonFan cto at lucifersoft.com
Wed Jan 16 05:15:15 EST 2002


>>> import httplib
>>> h = httplib.HTTP('www.cwi.nl')
>>> h.putrequest('GET', '/index.html')
>>> h.putheader('Accept', 'text/html')
>>> h.putheader('Accept', 'text/plain')
>>> h.endheaders()
>>> errcode, errmsg, headers = h.getreply()
>>> print errcode # Should be 200
>>> f = h.getfile()
>>> data = f.read() # Get the raw HTML
>>> f.close()
Python Library Reference
How to get web page through a proxy server?



More information about the Python-list mailing list