Re: [Tutor] urllib2.urlopen()

2012-10-14 Thread eryksun
On Sun, Oct 14, 2012 at 5:44 AM, Ray Jones wrote: > > I have often used help() to find my way around imported libraries. I > didn't realize it would also help with instances. That's good to know. help(e) shows info for the instance's class, such as methods and data descriptors (i.e. properties, s

Re: [Tutor] urllib2.urlopen()

2012-10-14 Thread Ray Jones
On 10/14/2012 02:26 AM, eryksun wrote: > e.hdrs['connection'] 'close' > e.hdrs.getheaders('connection') ['close'] I have often used help() to find my way around imported libraries. I didn't realize it would also help with instances. That's good to know. Ray __

Re: [Tutor] urllib2.urlopen()

2012-10-14 Thread eryksun
On Sun, Oct 14, 2012 at 2:15 AM, Ray Jones wrote: > > I can iterate through e.info() with a 'for' loop, but all I get as a > result is: > > connection > content-type > www-authenticate > content-length urllib2.HTTPError inherits from both urllib2.URLError and urllib.addinfourl (see help(e)). An i

Re: [Tutor] urllib2.urlopen()

2012-10-14 Thread Ray Jones
On 10/13/2012 11:55 PM, Brian van den Broek wrote: > On 14 October 2012 02:15, Ray Jones wrote: >> On 10/13/2012 07:50 PM, Steven D'Aprano wrote: > > >>> If you can do `print e.info()`, then you can also do `info = e.info()` >>> and inspect the info programmatically. >>> >> One would expect that

Re: [Tutor] urllib2.urlopen()

2012-10-13 Thread Brian van den Broek
On 14 October 2012 02:15, Ray Jones wrote: > On 10/13/2012 07:50 PM, Steven D'Aprano wrote: >> If you can do `print e.info()`, then you can also do `info = e.info()` >> and inspect the info programmatically. >> > One would expect that to be true. But when I do info = e.info(), info is > . > > Wh

Re: [Tutor] urllib2.urlopen()

2012-10-13 Thread Ray Jones
On 10/13/2012 07:50 PM, Steven D'Aprano wrote: > On 14/10/12 12:45, Ray Jones wrote: >> On 10/13/2012 05:09 PM, Brian van den Broek wrote: >>> On 13 October 2012 19:44, Ray Jones wrote: I am attempting to capture url headers and have my script make decisions based on the content of

Re: [Tutor] urllib2.urlopen()

2012-10-13 Thread Steven D'Aprano
On 14/10/12 12:45, Ray Jones wrote: On 10/13/2012 05:09 PM, Brian van den Broek wrote: On 13 October 2012 19:44, Ray Jones wrote: I am attempting to capture url headers and have my script make decisions based on the content of those headers. Here is what I am using in the relative portion of

Re: [Tutor] urllib2.urlopen()

2012-10-13 Thread Ray Jones
On 10/13/2012 05:09 PM, Brian van den Broek wrote: > On 13 October 2012 19:44, Ray Jones wrote: >> I am attempting to capture url headers and have my script make decisions >> based on the content of those headers. >> >> Here is what I am using in the relative portion of my script: >> >> try: >>

Re: [Tutor] urllib2.urlopen()

2012-10-13 Thread Brian van den Broek
On 13 October 2012 19:44, Ray Jones wrote: > I am attempting to capture url headers and have my script make decisions > based on the content of those headers. > > Here is what I am using in the relative portion of my script: > > try: > urllib2.urlopen('http://myurl.org') > except urllib2.HTTPE

[Tutor] urllib2.urlopen()

2012-10-13 Thread Ray Jones
I am attempting to capture url headers and have my script make decisions based on the content of those headers. Here is what I am using in the relative portion of my script: try: urllib2.urlopen('http://myurl.org') except urllib2.HTTPError, e: In the case of authentication error, I can print

Re: [Tutor] urllib2.urlopen(....., timeout=)

2012-09-07 Thread eryksun
On Fri, Sep 7, 2012 at 11:32 AM, Dave Angel wrote: > > I'm curious why the docstring says... timeout = > but have no clues for you. socket._GLOBAL_DEFAULT_TIMEOUT is an object(). In other words, it's an "object object". Also, that's not from the docstring but the call signature. The functio

Re: [Tutor] urllib2.urlopen(....., timeout=)

2012-09-07 Thread Ray Jones
On 09/07/2012 08:32 AM, Dave Angel wrote: > On 09/07/2012 11:16 AM, Ray Jones wrote: >> 2.7.3 >> According to the docs, urlopen has a timeout capability. But it says >> that the timeout = '' >> >> I've tried integers as the timeout value, I've tried floatsit >> doesn't complain about my values,

Re: [Tutor] urllib2.urlopen(....., timeout=)

2012-09-07 Thread Ray Jones
On 09/07/2012 08:33 AM, Steven D'Aprano wrote: > On 08/09/12 01:16, Ray Jones wrote: >> 2.7.3 >> According to the docs, urlopen has a timeout capability. But it says >> that the timeout = '' > > Which docs are those? According to these docs: > > http://docs.python.org/library/urllib2.html > > "The

Re: [Tutor] urllib2.urlopen(....., timeout=)

2012-09-07 Thread Steven D'Aprano
On 08/09/12 01:16, Ray Jones wrote: 2.7.3 According to the docs, urlopen has a timeout capability. But it says that the timeout = '' Which docs are those? According to these docs: http://docs.python.org/library/urllib2.html "The optional timeout parameter specifies a timeout in seconds for bl

Re: [Tutor] urllib2.urlopen(....., timeout=)

2012-09-07 Thread Dave Angel
On 09/07/2012 11:16 AM, Ray Jones wrote: > 2.7.3 > According to the docs, urlopen has a timeout capability. But it says > that the timeout = '' > > I've tried integers as the timeout value, I've tried floatsit > doesn't complain about my values, but neither does it timeout. Can > anyone point m

[Tutor] urllib2.urlopen(....., timeout=)

2012-09-07 Thread Ray Jones
2.7.3 According to the docs, urlopen has a timeout capability. But it says that the timeout = '' I've tried integers as the timeout value, I've tried floatsit doesn't complain about my values, but neither does it timeout. Can anyone point me to the solution to getting the urlopen to timeout if

Re: [Tutor] urllib2.urlopen(url)

2008-04-20 Thread Monika Jisswel
Hi Martin, print 'status:', response.status > print 'reason:', response.reason > print 'document:', response.read() > This is definitly what i was looking for and did not know in which module to look. Thank you so much for the code illusration. Monika. 2008/4/20, Martin Walsh <[EMAIL PROTECTED

Re: [Tutor] urllib2.urlopen(url)

2008-04-20 Thread Martin Walsh
Monika Jisswel wrote: > Hi, > > can i stop urllib2.urlopen() from following redirects automatically ? It doesn't answer your question directly, but if you care more about the initial request/response than the content at the other end of a redirect -- you can use httplib. It might look something

[Tutor] urllib2.urlopen(url)

2008-04-18 Thread Monika Jisswel
Hi, can i stop urllib2.urlopen() from following redirects automatically ? one more question i had in mind, the function urllib2.urlopen.geturl() does get me what i want but does it do the download of the page i was redirected to ? or just downloads the initial page that actually does the redir