The urllib2 module defines functions and classes which help in opening URLs (mostly HTTP) in a complex world -- basic and digest authentication, redirections and more.
The urllib2 module defines the following functions:
url[, data]) |
data should be a string, which specifies additional data to send to the server. In HTTP requests, which are the only ones that support data, it should be a buffer in the format of application/x-www-form-urlencoded, for example one returned from urllib.urlencode().
This function returns a file-like object with two additional methods:
Raises URLError on errors.
opener) |
[handler, ...]) |
If the Python installation has SSL support (socket.ssl() exists), HTTPSHandler will also be added.
Beginning in Python 2.3, a BaseHandler subclass may also
change its handler_order member variable to modify its
position in the handlers list. Besides ProxyHandler, which has
handler_order of 100
, all handlers currently have it
set to 500
.
The following exceptions are raised as appropriate:
The following classes are provided:
url[, data[, headers]]) |
url should be a string which is a valid URL. For a description of data see the add_data() description. headers should be a dictionary, and will be treated as if add_header() was called with each key and value as arguments.
) |
) |
) |
) |
[proxies]) |
) |
(realm, uri) -> (user, password)
mappings.
) |
(realm, uri) -> (user, password)
mappings.
A realm of None
is considered a catch-all realm, which is searched
if no other realm fits.
[password_mgr]) |
[password_mgr]) |
[password_mgr]) |
[password_mgr]) |
[password_mgr]) |
[password_mgr]) |
) |
) |
) |
) |
) |
) |
) |