Re: [Tutor] How to use urllib2.https_open with SSL support in Windows XP for python 2.5.2]
On Mon, Aug 18, 2008 at 9:36 PM, xbmuncher [EMAIL PROTECTED] 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:\Documents and Settings\user\Desktop\https_query.py, line 16, in module handle = urllib2.urlopen(req) File C:\Python25\lib\urllib2.py, line 124, in urlopen return _opener.open(url, data) File C:\Python25\lib\urllib2.py, line 381, in open response = self._open(req, data) File C:\Python25\lib\urllib2.py, line 399, in _open '_open', req) File C:\Python25\lib\urllib2.py, line 360, in _call_chain result = func(*args) File C:\Python25\lib\urllib2.py, line 1115, in https_open return self.do_open(httplib.HTTPSConnection, req) File C:\Python25\lib\urllib2.py, line 1080, in do_open r = h.getresponse() File C:\Python25\lib\httplib.py, line 928, in getresponse response.begin() File C:\Python25\lib\httplib.py, line 385, in begin version, status, reason = self._read_status() File C:\Python25\lib\httplib.py, line 349, in _read_status raise BadStatusLine(line) BadStatusLine What URL are you trying this against? The URL in your code https://url.com; doesn't seem to respond at all so I can't reproduce your error. Have you tried against a well known HTTPS endpoint like https://mail.google.com;? What happens? I'll try to guess anyway .. the Status Line in an HTTP response is the first line that gives the response code, something like HTTP/1.1 200 OK. Maybe your server is returning malformed headers? See below for more: http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to use urllib2.https_open with SSL support in Windows XP for python 2.5.2
On Mon, Aug 18, 2008 at 9:26 PM, xbmuncher [EMAIL PROTECTED] wrote: On Mon, Aug 18, 2008 at 8:44 PM, Kent Johnson [EMAIL PROTECTED] wrote: On Mon, Aug 18, 2008 at 12:40 PM, xbmuncher [EMAIL PROTECTED] wrote: I wanted to use the urllib2.https_open() but it said the module did not exist. I'm not aware of a urllib2.https_open() function. I think you just give an https url to urllib2.urlopen(). Can you show us your actual code and error message? Kent http://docs.python.org/lib/https-handler-objects.html I accessed it like this: urllib2.https_open(req) Its probably the syntax formation of using this https functionality that I have wrong. Maybe you can show me how. That method is part of the HTTPSHandler class as the docs page you cited implies. I believe this is what urllib2.urlopen instantiates once it parses your URL and notices the https scheme. You don't need to instantiate that handler and invoke that method directly. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to use urllib2.https_open with SSL support in Windows XP for python 2.5.2]
On Mon, Aug 18, 2008 at 9:36 PM, xbmuncher [EMAIL PROTECTED] 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 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to use urllib2.https_open with SSL support in Windows XP for python 2.5.2]
On Mon, Aug 18, 2008 at 4:25 PM, bob gailer [EMAIL PROTECTED] wrote: Forwarding to the list. Please always reply to the list. -- Bob Gailer Chapel Hill NC 919-636-4239 When we take the time to be aware of our feelings and needs we have more satisfying interatctions with others. Nonviolent Communication provides tools for this awareness. As a coach and trainer I can assist you in learning this process. What is YOUR biggest relationship challenge? I wanted to use the urllib2.https_open() but it said the module did not exist. The manual says I need SSL support installed. I've done some searching.. but I haven't been able to find an official implementation of SSL support for python 2.5 for windows. If its required for urllib2 I assume its part of the official python library of modules, is there an MSI installer or official place to get the SSL support that was mentioned in the urllib2 doc page? I just want to use the https capability of urllib2. -thanks Calling urlopen with an https scheme should be sufficient as long as python with SSL support is installed. I have the ActiveState Python 2.5.2 distribution on Windows XP and it seems to work fine: In [3]: response = urllib2.urlopen('https://google.com') In [4]: response = urllib2.urlopen('https://mail.google.com') In [5]: html = response.read() ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to use urllib2.https_open with SSL support in Windows XP for python 2.5.2
On Mon, Aug 18, 2008 at 12:40 PM, xbmuncher [EMAIL PROTECTED] wrote: I wanted to use the urllib2.https_open() but it said the module did not exist. I'm not aware of a urllib2.https_open() function. I think you just give an https url to urllib2.urlopen(). Can you show us your actual code and error message? Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to use urllib2.https_open with SSL support in Windows XP for python 2.5.2
On Mon, Aug 18, 2008 at 8:44 PM, Kent Johnson [EMAIL PROTECTED] wrote: On Mon, Aug 18, 2008 at 12:40 PM, xbmuncher [EMAIL PROTECTED] wrote: I wanted to use the urllib2.https_open() but it said the module did not exist. I'm not aware of a urllib2.https_open() function. I think you just give an https url to urllib2.urlopen(). Can you show us your actual code and error message? Kent http://docs.python.org/lib/https-handler-objects.html I accessed it like this: urllib2.https_open(req) Its probably the syntax formation of using this https functionality that I have wrong. Maybe you can show me how. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to use urllib2.https_open with SSL support in Windows XP for python 2.5.2]
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:\Documents and Settings\user\Desktop\https_query.py, line 16, in module handle = urllib2.urlopen(req) File C:\Python25\lib\urllib2.py, line 124, in urlopen return _opener.open(url, data) File C:\Python25\lib\urllib2.py, line 381, in open response = self._open(req, data) File C:\Python25\lib\urllib2.py, line 399, in _open '_open', req) File C:\Python25\lib\urllib2.py, line 360, in _call_chain result = func(*args) File C:\Python25\lib\urllib2.py, line 1115, in https_open return self.do_open(httplib.HTTPSConnection, req) File C:\Python25\lib\urllib2.py, line 1080, in do_open r = h.getresponse() File C:\Python25\lib\httplib.py, line 928, in getresponse response.begin() File C:\Python25\lib\httplib.py, line 385, in begin version, status, reason = self._read_status() File C:\Python25\lib\httplib.py, line 349, in _read_status raise BadStatusLine(line) BadStatusLine On Mon, Aug 18, 2008 at 4:57 PM, arsyed [EMAIL PROTECTED] wrote: On Mon, Aug 18, 2008 at 4:25 PM, bob gailer [EMAIL PROTECTED] wrote: Forwarding to the list. Please always reply to the list. -- Bob Gailer Chapel Hill NC 919-636-4239 When we take the time to be aware of our feelings and needs we have more satisfying interatctions with others. Nonviolent Communication provides tools for this awareness. As a coach and trainer I can assist you in learning this process. What is YOUR biggest relationship challenge? I wanted to use the urllib2.https_open() but it said the module did not exist. The manual says I need SSL support installed. I've done some searching.. but I haven't been able to find an official implementation of SSL support for python 2.5 for windows. If its required for urllib2 I assume its part of the official python library of modules, is there an MSI installer or official place to get the SSL support that was mentioned in the urllib2 doc page? I just want to use the https capability of urllib2. -thanks Calling urlopen with an https scheme should be sufficient as long as python with SSL support is installed. I have the ActiveState Python 2.5.2 distribution on Windows XP and it seems to work fine: In [3]: response = urllib2.urlopen('https://google.com') In [4]: response = urllib2.urlopen('https://mail.google.com') In [5]: html = response.read() ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor