faqts : Computers : Programming : Languages : Python

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

22 of 26 people (85%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

How do I retrieve an https (SSL) url?

Mar 10th, 2008 04:08
Prince Red, Sheana blogs, Gerhard Haering, Christopher Arndt, Satish, Michael Chermside,


The module 'M2Crypto' (an interface to the OpenSSL library) provides a
submodule 'm2urllib', that works similar to the standard library 
module
'urllib'.

An example from the directory 'demo/ssl' from the distribution
('url_cli.py'):

from M2Crypto import m2urllib

def test_urllib():
    url = m2urllib.FancyURLopener()
    url.addheader('Connection', 'close')
    u = url.open('https://127.0.0.1:9443/')
    while 1:
        data = u.read()
        if not data: break
        print data
    u.close()

You can find this module at 'http://www.post1.com/home/ngps/m2/'


Python versions 2.0 and later can be built with client-side SSL 
support
built into the socket module. HTTPS URLs can the be accessed just like
HTTP URLs, for example with urllib.urlopen().