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:
Open the URL url, which can be either a string or a Request
object (currently the code checks that it really is a Request
instance, or an instance of a subclass of Request).
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:
geturl() -- return the URL of the resource retrieved
info() -- return the meta-information of the page, as
a dictionary-like object
Install an OpenerDirector instance as the default opener.
The code does not check for a real OpenerDirector, and any
class with the appropriate interface will work.
Return an OpenerDirector instance, which chains the
handlers in the order given. handlers can be either instances
of BaseHandler, or subclasses of BaseHandler (in
which case it must be possible to call the constructor without
any parameters). Instances of the following classes will be in
front of the handlers, unless the handlers contain
them, instances of them or subclasses of them:
A subclass of URLError, it can also function as a
non-exceptional file-like return value (the same thing that
urlopen() returns). This is useful when handling exotic
HTTP errors, such as requests for authentication.
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.
Cause requests to go through a proxy.
If proxies is given, it must be a dictionary mapping
protocol names to URLs of proxies.
The default is to read the list of proxies from the environment
variables protocol_proxy.
Keep a database of
(realm, uri) -> (user, password) mappings.
A realm of None is considered a catch-all realm, which is searched
if no other realm fits.
This is a mixin class that helps with HTTP authentication, both
to the remote host and to a proxy.
password_mgr, if given, should be something that is compatible
with HTTPPasswordMgr; refer to section 11.5.6
for information on the interface that must be supported.
Handle authentication with the remote host.
password_mgr, if given, should be something that is compatible
with HTTPPasswordMgr; refer to section 11.5.6
for information on the interface that must be supported.
Handle authentication with the proxy.
password_mgr, if given, should be something that is compatible
with HTTPPasswordMgr; refer to section 11.5.6
for information on the interface that must be supported.
This is a mixin class that helps with HTTP authentication, both
to the remote host and to a proxy.
password_mgr, if given, should be something that is compatible
with HTTPPasswordMgr; refer to section 11.5.6
for information on the interface that must be supported.
Handle authentication with the remote host.
password_mgr, if given, should be something that is compatible
with HTTPPasswordMgr; refer to section 11.5.6
for information on the interface that must be supported.
Handle authentication with the proxy.
password_mgr, if given, should be something that is compatible
with HTTPPasswordMgr; refer to section 11.5.6
for information on the interface that must be supported.