Urlib.py not working with https?

In my python application, I'm trying to open https-url, but I get:

File "C:\Python26\lib\urllib.py", line 215, in open_unknown raise IOError, ('url error', 'unknown url type', type) IOError: [Errno url error] unknown url type: 'https' 

my code is:

 import urllib def generate_embedded_doc(doc_id): url = "https://docs.google.com/document/ub?id=" + doc_id + "&embedded=true" src = urllib.urlopen(url).read() ... return src 
+4
source share
3 answers

urllib and Python 2.6 have SSL support, and your sample code is great for me. Perhaps your Python is built without SSL support? Try reinstalling Python 2.6 (or better, 2.7) and use the original assembly from python.org .

In the Google App Engine, try using the API directly:

 from google.appengine.api import urlfetch url = "https://www.google.com/" result = urlfetch.fetch(url) if result.status_code == 200: doSomethingWithResult(result.content) 
+3
source

To support SSL, you need to compile Python with OpenSSL . For example, in Ubuntu lucid, you must install the libcurl4-openssl-dev module and then rebuild Python.

+6
source

Try urllib2 instead.

I had the same problem with urllib on OSX 10.6 using python 2.6.6 from macports. Switching to urllib2 fixed it.

+1
source

All Articles