[Tutor] urllib2.urlopen()
Brian van den Broek
brian.van.den.broek at gmail.com
Sun Oct 14 08:55:55 CEST 2012
On 14 October 2012 02:15, Ray Jones <crawlzone at gmail.com> wrote:
> On 10/13/2012 07:50 PM, Steven D'Aprano wrote:
<snip>
>> 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
> <httplib.HTTPMessage instance at 0x85bdd2c>.
>
> When I print e.info(), I get the following:
>
> Content-Type: text/html
> Connection: close
> WWW-Authenticate: Basic realm="xxxx"
> Content-Length: xx
>
> 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
>
> In other words, I get the headers but not the corresponding values.
Ray,
That smells rather like you are dealing with a dictionary. What
happens if you try
e.info()["connection"]
Best,
Brian vdB
More information about the Tutor
mailing list