> Noah wrote:
> 
> What is the most straight-forward way for me to use Python to
> download web pages over HTTPS? The doc pages for urllib2 don't
> give many examples, and I don't think I have SSL loaded either
> (I don't see socket.ssl). Basically, I want to write a web screen
> scraping application similar to Yodlee. I need to login to a secure
> page and download the HTML and then parse it for content.
> 
> I looked at mxcrypto and m2crypto, but none of these had simple
> examples of just client HTTPS grabbing web pages from a server.

i use m2crypto something like this:
        
        from M2Crypto import SSL, httpslib

        # setup an SSL context
        ctx = SSL.Context ('sslv23')
        ctx.load_verify_location ('ca.pem')
        ctx.set_verify (SSL.verify_peer, 10)

        https = httpslib.HTTPSConnection (
                'www.myfoo.com', 443, ssl_context=ctx
                ))

        https.request (
                'GET',                  # method
                '/servlet/login',       # URI
                '',                     # request string if any (POST data)
                {}                      # HTTP request headers
                )
        response = https.response ()
        if response.status != 200:
                print 'Error: %d' % response.status
        else:
                page = response.read ()
                response.close ()
                print page
        
        
> Maybe I could build a proxy server in Java or C...

don't. use stunnel instead (http://www.stunnel.org).



Laurent Szyster
_______________________________________________
ActivePython mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activepython

Reply via email to