Class to open URLs. This is a class rather than just a subroutine because we may need more than one set of global protocol-specific options. Note -- this is a base class for those who don't want the automatic handling of errors type 302 (relocated) and 401 (authorization needed).
There are no base classes.
There are no implemented interfaces.
version
(type:
str
)
'Python-urllib/1.16'
addheader(*args)
Add a header to be used by the HTTP interface only
e.g. u.addheader(Accept
, sound/basic
)
cleanup()
close()
http_error(url, fp, errcode, errmsg, headers, data=None)
Handle http errors. Derived class can override this, or provide specific handlers named http_error_DDD where DDD is the 3-digit error code.
http_error_default(url, fp, errcode, errmsg, headers)
Default error handler: close the connection and raise IOError.
open(fullurl, data=None)
Use URLopener().open(file) instead of open(file, r
).
open_data(url, data=None)
Use "data" URL.
open_file(url)
Use local file or FTP depending on form of URL.
open_ftp(url)
Use FTP protocol.
open_gopher(url)
Use Gopher protocol.
open_http(url, data=None)
Use HTTP protocol.
open_https(url, data=None)
Use HTTPS protocol.
open_local_file(url)
Use local file.
open_unknown(fullurl, data=None)
Overridable interface to open unknown URL type.
open_unknown_proxy(proxy, fullurl, data=None)
Overridable interface to open unknown URL type.
retrieve(url, filename=None, reporthook=None, data=None)
retrieve(url) returns (filename, headers) for a local object or (tempfilename, headers) for a remote object.