Wednesday, October 20, 2010

Python: Accessing https pages from behing an authenticating proxy server

from urllib2 import ProxyHandler, build_opener

proxyMap = {'https': 'http://(user):(pass)@(proxyhost):(proxypass)/'}
proxy = ProxyHandler(proxyMap)
opener = build_opener(proxy)
u = opener.open('https://somehttpspage')
data = u.read()



charset = u.info().getparam('charset') # Python 2
print 'CharSet %s' % charset
print '------------------------------------------------------------------------'
print data

No comments: