P
Phillip
Hi.
I'm having some anoying trouble trying to establish a https connection.
I've even switched Python Versions (from 2.2.3 to 2.3.3), but the Errors
remain basically the same, allthough they now come in nice XML .
Here are some examples:
My last desperate try (which is way off the book):import re
import base64
import httplib
import urllib2
import string
# don't know if I need this one, it doesn't fix anything it seems...
import socket
suffix = r"blah"
prefix = r"jada"
basicAuth = base64.encodestring(prefix + r":" + suffix)
kopf = {"Basic": basicAuth}
req = urllib2.Request(url="https://myurl/", data="", headers = kopf)
fileLines = urllib2.https_open(req)
print "Recieved:"
print fileLines
<<<
This is the Error it throws:
./gethttps.py
Traceback (most recent call last):
File "./gethttps.py", line 30, in ?
fileLines = urllib2.https_open(req)
AttributeError: 'module' object has no attribute 'https_open'
The obvious one doesn't work either ALTHOUGH it's an Example from the
official urllib2 docs!!!:import re
import base64
import httplib
import urllib2
import string
import socket
suffix = r"blah"
prefix = r"jada"
basicAuth = base64.encodestring(prefix + r":" + suffix)
kopf = {"Basic": basicAuth}
req = urllib2.Request(url="https://myurl/", data="", headers = kopf)
fileLines = urllib2.urlopen(req)
print "Recieved:"
print fileLines
<<<
Here are the Errors throwed:
Traceback (most recent call last):
File "./gethttps.py", line 25, in ?
fileLines = urllib2.urlopen(req)
File "/usr/local/lib/python2.3/urllib2.py", line 129, in urlopen
return _opener.open(url, data)
File "/usr/local/lib/python2.3/urllib2.py", line 331, in open
'unknown_open', req)
File "/usr/local/lib/python2.3/urllib2.py", line 306, in _call_chain
result = func(*args)
File "/usr/local/lib/python2.3/urllib2.py", line 914, in unknown_open
raise URLError('unknown url type: %s' % type)
urllib2.URLError: <urlopen error unknown url type: https>
Does anybody have any Idea how I can open a https connection using
Python? The http, urllib and urllib2 in a whole seem quite a messy bunch
and I have had no success so far trying to grasp how to handle large
parts of them.
There are traces on the web saying that some socket stuff needs ssl
compiled into them in order for https stuff to work, but they seem old
and since I'm using the fresh original sources from www.python.org on a
Debian Linux system I presume that compiling should work A-OK.
If anybody thinks this is likeley to be a compiling issue, how and where
do I change the original source distribution to support https? In some
make or configure file maybe? I have no Idea. How do I find out if ssl
is supported in my install?
I'd be glad if someone could help, this all is driving me nuts.
Thanks.
Phillip
BTW: Since there is apsolutely no documentation on how to use the larger
part of urllib2's stuff on python.org it would be nice if someone could
also point out a howto or some working examples of how and in which
situations to use these classes and methods, such as OpenerDirector(???)
and such.
I'm having some anoying trouble trying to establish a https connection.
I've even switched Python Versions (from 2.2.3 to 2.3.3), but the Errors
remain basically the same, allthough they now come in nice XML .
Here are some examples:
My last desperate try (which is way off the book):import re
import base64
import httplib
import urllib2
import string
# don't know if I need this one, it doesn't fix anything it seems...
import socket
suffix = r"blah"
prefix = r"jada"
basicAuth = base64.encodestring(prefix + r":" + suffix)
kopf = {"Basic": basicAuth}
req = urllib2.Request(url="https://myurl/", data="", headers = kopf)
fileLines = urllib2.https_open(req)
print "Recieved:"
print fileLines
<<<
This is the Error it throws:
./gethttps.py
Traceback (most recent call last):
File "./gethttps.py", line 30, in ?
fileLines = urllib2.https_open(req)
AttributeError: 'module' object has no attribute 'https_open'
The obvious one doesn't work either ALTHOUGH it's an Example from the
official urllib2 docs!!!:import re
import base64
import httplib
import urllib2
import string
import socket
suffix = r"blah"
prefix = r"jada"
basicAuth = base64.encodestring(prefix + r":" + suffix)
kopf = {"Basic": basicAuth}
req = urllib2.Request(url="https://myurl/", data="", headers = kopf)
fileLines = urllib2.urlopen(req)
print "Recieved:"
print fileLines
<<<
Here are the Errors throwed:
Traceback (most recent call last):
File "./gethttps.py", line 25, in ?
fileLines = urllib2.urlopen(req)
File "/usr/local/lib/python2.3/urllib2.py", line 129, in urlopen
return _opener.open(url, data)
File "/usr/local/lib/python2.3/urllib2.py", line 331, in open
'unknown_open', req)
File "/usr/local/lib/python2.3/urllib2.py", line 306, in _call_chain
result = func(*args)
File "/usr/local/lib/python2.3/urllib2.py", line 914, in unknown_open
raise URLError('unknown url type: %s' % type)
urllib2.URLError: <urlopen error unknown url type: https>
Does anybody have any Idea how I can open a https connection using
Python? The http, urllib and urllib2 in a whole seem quite a messy bunch
and I have had no success so far trying to grasp how to handle large
parts of them.
There are traces on the web saying that some socket stuff needs ssl
compiled into them in order for https stuff to work, but they seem old
and since I'm using the fresh original sources from www.python.org on a
Debian Linux system I presume that compiling should work A-OK.
If anybody thinks this is likeley to be a compiling issue, how and where
do I change the original source distribution to support https? In some
make or configure file maybe? I have no Idea. How do I find out if ssl
is supported in my install?
I'd be glad if someone could help, this all is driving me nuts.
Thanks.
Phillip
BTW: Since there is apsolutely no documentation on how to use the larger
part of urllib2's stuff on python.org it would be nice if someone could
also point out a howto or some working examples of how and in which
situations to use these classes and methods, such as OpenerDirector(???)
and such.