[Tutor] How to use urllib2.https_open with SSL support in Windows XP for python 2.5.2]

Kent Johnson kent37 at tds.net
Tue Aug 19 12:36:29 CEST 2008


On Mon, Aug 18, 2008 at 9:36 PM, xbmuncher <xboxmuncher at gmail.com> wrote:
> I tried it just like both of you suggested and sent a req object straight to
> urlopen. Here is my code:
> import urllib2
> url = 'https://url.com'
> headers = {
> 'User-Agent' : 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)',
> 'Accept' :
> 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
> 'Accept-Language' : 'fr-fr,en-us;q=0.7,en;q=0.3',
> 'Accept-Charset' : 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'
> }
>
> #None = GET; set values to use POST
> req = urllib2.Request(url, None, headers)
> handle = urllib2.urlopen(req)
> resp = handle.read()
> print resp.geturl()
> print resp.info()
> print resp
>
> resp.close()
>
>
>
> Here is the error msg:
> Traceback (most recent call last):
>
>   File "C:\Python25\lib\httplib.py", line 349, in _read_status
>     raise BadStatusLine(line)
> BadStatusLine

Looking at the source for httplib, that error is raised when no status
line response is received from the host. Are you sure you are using a
correct URL?

Kent


More information about the Tutor mailing list