[Tutor] urllib2.urlopen()

Ray Jones crawlzone at gmail.com
Sun Oct 14 03:45:14 CEST 2012


On 10/13/2012 05:09 PM, Brian van den Broek wrote:
> On 13 October 2012 19:44, Ray Jones <crawlzone at gmail.com> 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.HTTPError, e:
>>
>> In the case of authentication error, I can print e.info() and get all
>> the relevant header information. But I don't want to print. I want the
>> information from the instance available to use in my script. How do I
>> accomplish that?
>>
>>
>> Ray
> ['__class__', '__delattr__', '__dict__', '__doc__', '__format__',
> '__getattribute__', '__getitem__', '__getslice__', '__hash__',
> '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__',
> '__repr__', '__setattr__', '__setstate__', '__sizeof__', '__str__',
> '__subclasshook__', '__unicode__', '__weakref__', 'args', 'errno',
> 'filename', 'message', 'reason', 'strerror']

Thanks for the response. I experimented some, but I am not even sure
what kinds of things to try. I mostly tried things like
E.__getattribute__() or print E.strerror, but nothing seemed to give me
what I was looking for.


Ray


More information about the Tutor mailing list