471,330 Members | 1,771 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,330 software developers and data experts.

How to get headers in urllib2 response

Can anyone provide an example how to find out the return code and
header from an urllib2 request?
For example
response = urllib2.urlopen('http://www.google.com').read().strip()
provides data
but I do not know if the return code was 200 or different.

Thanks

Sep 15 '07 #1
1 3684
js
How about using httplib?
http://docs.python.org/lib/httplib-examples.html

HTTPResponse has getheaders() method, too.

On 9/15/07, Johny <py****@hope.czwrote:
Can anyone provide an example how to find out the return code and
header from an urllib2 request?
For example
response = urllib2.urlopen('http://www.google.com').read().strip()
provides data
but I do not know if the return code was 200 or different.

Thanks

--
http://mail.python.org/mailman/listinfo/python-list
Sep 15 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by O. Koch | last post: by
1 post views Thread by Doug Gray | last post: by
1 post views Thread by Doug Farrell | last post: by
7 posts views Thread by itay_k | last post: by
reply views Thread by Ali.Sabil | last post: by
1 post views Thread by Magnus.Moraberg | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.