SSL (HTTPS) with 2.4

Bloke rhall at thiess.com.au
Wed May 18 09:52:43 EDT 2005


I just tried the https connection through a friends internet connection
which uses a transparent proxy as follows:

import urllib2
f = urllib2.urlopen('https://www.directshares.com.au/')
print f.headers
print f.read()
f.close()

This works fine.  So it must be a problem with either the proxyhandler
(in Python) or our proxy server.  Given that I can connect to the site
through the proxy with a web browser, it must be something to do with
my the way I have set up the proxy handler in python.  I have read
multiple ways of setting up the connection, and this is the only way I
can get it to run with http:

import urllib2

proxy_info = {
    'user' : 'me',
    'pass' : 'password',
    'host' : 'companyproxy.com.au',
    'port' : 8008 }

# build a new opener that uses a proxy requiring authorization
proxy_support =
urllib2.ProxyHandler({"http":"http://%(user)s:%(pass)s@%(host)s:%(port)d"
% proxy_info})
opener = urllib2.build_opener(proxy_support, urllib2.HTTPHandler)

# install it
urllib2.install_opener(opener)


Is there a better way for me to do this?




More information about the Python-list mailing list