How to get the code of the headers through urllib?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
You can use urllib2 as well:
Note that
HTTPError
is a subclass ofURLError
which stores the HTTP status code.The getcode() method (Added in python2.6) returns the HTTP status code that was sent with the response, or None if the URL is no HTTP URL.
For Python 3: