doc_content
stringlengths
1
386k
doc_id
stringlengths
5
188
addTest(test) Add a TestCase or TestSuite to the suite.
python.library.unittest#unittest.TestSuite.addTest
addTests(tests) Add all the tests from an iterable of TestCase and TestSuite instances to this test suite. This is equivalent to iterating over tests, calling addTest() for each element.
python.library.unittest#unittest.TestSuite.addTests
countTestCases() Return the number of tests represented by this test object, including all individual tests and sub-suites.
python.library.unittest#unittest.TestSuite.countTestCases
debug() Run the tests associated with this suite without collecting the result. This allows exceptions raised by the test to be propagated to the caller and can be used to support running tests under a debugger.
python.library.unittest#unittest.TestSuite.debug
run(result) Run the tests associated with this suite, collecting the result into the test result object passed as result. Note that unlike TestCase.run(), TestSuite.run() requires the result object to be passed in.
python.library.unittest#unittest.TestSuite.run
__iter__() Tests grouped by a TestSuite are always accessed by iteration. Subclasses can lazily provide tests by overriding __iter__(). Note that this method may be called several times on a single suite (for example when counting tests or comparing for equality) so the tests returned by repeated iterations before Te...
python.library.unittest#unittest.TestSuite.__iter__
class unittest.TextTestResult(stream, descriptions, verbosity) A concrete implementation of TestResult used by the TextTestRunner. New in version 3.2: This class was previously named _TextTestResult. The old name still exists as an alias but is deprecated.
python.library.unittest#unittest.TextTestResult
class unittest.TextTestRunner(stream=None, descriptions=True, verbosity=1, failfast=False, buffer=False, resultclass=None, warnings=None, *, tb_locals=False) A basic test runner implementation that outputs results to a stream. If stream is None, the default, sys.stderr is used as the output stream. This class has a f...
python.library.unittest#unittest.TextTestRunner
run(test) This method is the main public interface to the TextTestRunner. This method takes a TestSuite or TestCase instance. A TestResult is created by calling _makeResult() and the test(s) are run and the results printed to stdout.
python.library.unittest#unittest.TextTestRunner.run
_makeResult() This method returns the instance of TestResult used by run(). It is not intended to be called directly, but can be overridden in subclasses to provide a custom TestResult. _makeResult() instantiates the class or callable passed in the TextTestRunner constructor as the resultclass argument. It defaults t...
python.library.unittest#unittest.TextTestRunner._makeResult
urllib — URL handling modules Source code: Lib/urllib/ urllib is a package that collects several modules for working with URLs: urllib.request for opening and reading URLs urllib.error containing the exceptions raised by urllib.request urllib.parse for parsing URLs urllib.robotparser for parsing robots.txt files
python.library.urllib
urllib.error — Exception classes raised by urllib.request Source code: Lib/urllib/error.py The urllib.error module defines the exception classes for exceptions raised by urllib.request. The base exception class is URLError. The following exceptions are raised by urllib.error as appropriate: exception urllib.error.URL...
python.library.urllib.error
exception urllib.error.ContentTooShortError(msg, content) This exception is raised when the urlretrieve() function detects that the amount of the downloaded data is less than the expected amount (given by the Content-Length header). The content attribute stores the downloaded (and supposedly truncated) data.
python.library.urllib.error#urllib.error.ContentTooShortError
exception urllib.error.HTTPError Though being an exception (a subclass of URLError), an HTTPError 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. code An HTTP status code as...
python.library.urllib.error#urllib.error.HTTPError
code An HTTP status code as defined in RFC 2616. This numeric value corresponds to a value found in the dictionary of codes as found in http.server.BaseHTTPRequestHandler.responses.
python.library.urllib.error#urllib.error.HTTPError.code
headers The HTTP response headers for the HTTP request that caused the HTTPError. New in version 3.4.
python.library.urllib.error#urllib.error.HTTPError.headers
reason This is usually a string explaining the reason for this error.
python.library.urllib.error#urllib.error.HTTPError.reason
exception urllib.error.URLError The handlers raise this exception (or derived exceptions) when they run into a problem. It is a subclass of OSError. reason The reason for this error. It can be a message string or another exception instance. Changed in version 3.3: URLError has been made a subclass of OSError i...
python.library.urllib.error#urllib.error.URLError
reason The reason for this error. It can be a message string or another exception instance.
python.library.urllib.error#urllib.error.URLError.reason
urllib.parse — Parse URLs into components Source code: Lib/urllib/parse.py This module defines a standard interface to break Uniform Resource Locator (URL) strings up in components (addressing scheme, network location, path etc.), to combine the components back into a URL string, and to convert a “relative URL” to an a...
python.library.urllib.parse
class urllib.parse.DefragResult(url, fragment) Concrete class for urldefrag() results containing str data. The encode() method returns a DefragResultBytes instance. New in version 3.2.
python.library.urllib.parse#urllib.parse.DefragResult
class urllib.parse.DefragResultBytes(url, fragment) Concrete class for urldefrag() results containing bytes data. The decode() method returns a DefragResult instance. New in version 3.2.
python.library.urllib.parse#urllib.parse.DefragResultBytes
class urllib.parse.ParseResult(scheme, netloc, path, params, query, fragment) Concrete class for urlparse() results containing str data. The encode() method returns a ParseResultBytes instance.
python.library.urllib.parse#urllib.parse.ParseResult
class urllib.parse.ParseResultBytes(scheme, netloc, path, params, query, fragment) Concrete class for urlparse() results containing bytes data. The decode() method returns a ParseResult instance. New in version 3.2.
python.library.urllib.parse#urllib.parse.ParseResultBytes
urllib.parse.parse_qs(qs, keep_blank_values=False, strict_parsing=False, encoding='utf-8', errors='replace', max_num_fields=None, separator='&') Parse a query string given as a string argument (data of type application/x-www-form-urlencoded). Data are returned as a dictionary. The dictionary keys are the unique query...
python.library.urllib.parse#urllib.parse.parse_qs
urllib.parse.parse_qsl(qs, keep_blank_values=False, strict_parsing=False, encoding='utf-8', errors='replace', max_num_fields=None, separator='&') Parse a query string given as a string argument (data of type application/x-www-form-urlencoded). Data are returned as a list of name, value pairs. The optional argument ke...
python.library.urllib.parse#urllib.parse.parse_qsl
urllib.parse.quote(string, safe='/', encoding=None, errors=None) Replace special characters in string using the %xx escape. Letters, digits, and the characters '_.-~' are never quoted. By default, this function is intended for quoting the path section of a URL. The optional safe parameter specifies additional ASCII c...
python.library.urllib.parse#urllib.parse.quote
urllib.parse.quote_from_bytes(bytes, safe='/') Like quote(), but accepts a bytes object rather than a str, and does not perform string-to-bytes encoding. Example: quote_from_bytes(b'a&\xef') yields 'a%26%EF'.
python.library.urllib.parse#urllib.parse.quote_from_bytes
urllib.parse.quote_plus(string, safe='', encoding=None, errors=None) Like quote(), but also replace spaces with plus signs, as required for quoting HTML form values when building up a query string to go into a URL. Plus signs in the original string are escaped unless they are included in safe. It also does not have s...
python.library.urllib.parse#urllib.parse.quote_plus
class urllib.parse.SplitResult(scheme, netloc, path, query, fragment) Concrete class for urlsplit() results containing str data. The encode() method returns a SplitResultBytes instance.
python.library.urllib.parse#urllib.parse.SplitResult
class urllib.parse.SplitResultBytes(scheme, netloc, path, query, fragment) Concrete class for urlsplit() results containing bytes data. The decode() method returns a SplitResult instance. New in version 3.2.
python.library.urllib.parse#urllib.parse.SplitResultBytes
urllib.parse.unquote(string, encoding='utf-8', errors='replace') Replace %xx escapes with their single-character equivalent. The optional encoding and errors parameters specify how to decode percent-encoded sequences into Unicode characters, as accepted by the bytes.decode() method. string may be either a str or a by...
python.library.urllib.parse#urllib.parse.unquote
urllib.parse.unquote_plus(string, encoding='utf-8', errors='replace') Like unquote(), but also replace plus signs with spaces, as required for unquoting HTML form values. string must be a str. Example: unquote_plus('/El+Ni%C3%B1o/') yields '/El Niño/'.
python.library.urllib.parse#urllib.parse.unquote_plus
urllib.parse.unquote_to_bytes(string) Replace %xx escapes with their single-octet equivalent, and return a bytes object. string may be either a str or a bytes object. If it is a str, unescaped non-ASCII characters in string are encoded into UTF-8 bytes. Example: unquote_to_bytes('a%26%EF') yields b'a&\xef'.
python.library.urllib.parse#urllib.parse.unquote_to_bytes
urllib.parse.unwrap(url) Extract the url from a wrapped URL (that is, a string formatted as <URL:scheme://host/path>, <scheme://host/path>, URL:scheme://host/path or scheme://host/path). If url is not a wrapped URL, it is returned without changes.
python.library.urllib.parse#urllib.parse.unwrap
urllib.parse.urldefrag(url) If url contains a fragment identifier, return a modified version of url with no fragment identifier, and the fragment identifier as a separate string. If there is no fragment identifier in url, return url unmodified and an empty string. The return value is a named tuple, its items can be a...
python.library.urllib.parse#urllib.parse.urldefrag
urllib.parse.urlencode(query, doseq=False, safe='', encoding=None, errors=None, quote_via=quote_plus) Convert a mapping object or a sequence of two-element tuples, which may contain str or bytes objects, to a percent-encoded ASCII text string. If the resultant string is to be used as a data for POST operation with th...
python.library.urllib.parse#urllib.parse.urlencode
urllib.parse.urljoin(base, url, allow_fragments=True) Construct a full (“absolute”) URL by combining a “base URL” (base) with another URL (url). Informally, this uses components of the base URL, in particular the addressing scheme, the network location and (part of) the path, to provide missing components in the rela...
python.library.urllib.parse#urllib.parse.urljoin
urllib.parse.SplitResult.geturl() Return the re-combined version of the original URL as a string. This may differ from the original URL in that the scheme may be normalized to lower case and empty components may be dropped. Specifically, empty parameters, queries, and fragment identifiers will be removed. For urldefr...
python.library.urllib.parse#urllib.parse.urllib.parse.SplitResult.geturl
urllib.parse.urlparse(urlstring, scheme='', allow_fragments=True) Parse a URL into six components, returning a 6-item named tuple. This corresponds to the general structure of a URL: scheme://netloc/path;parameters?query#fragment. Each tuple item is a string, possibly empty. The components are not broken up into smal...
python.library.urllib.parse#urllib.parse.urlparse
urllib.parse.urlsplit(urlstring, scheme='', allow_fragments=True) This is similar to urlparse(), but does not split the params from the URL. This should generally be used instead of urlparse() if the more recent URL syntax allowing parameters to be applied to each segment of the path portion of the URL (see RFC 2396)...
python.library.urllib.parse#urllib.parse.urlsplit
urllib.parse.urlunparse(parts) Construct a URL from a tuple as returned by urlparse(). The parts argument can be any six-item iterable. This may result in a slightly different, but equivalent URL, if the URL that was parsed originally had unnecessary delimiters (for example, a ? with an empty query; the RFC states th...
python.library.urllib.parse#urllib.parse.urlunparse
urllib.parse.urlunsplit(parts) Combine the elements of a tuple as returned by urlsplit() into a complete URL as a string. The parts argument can be any five-item iterable. This may result in a slightly different, but equivalent URL, if the URL that was parsed originally had unnecessary delimiters (for example, a ? wi...
python.library.urllib.parse#urllib.parse.urlunsplit
urllib.request — Extensible library for opening URLs Source code: Lib/urllib/request.py The urllib.request module defines functions and classes which help in opening URLs (mostly HTTP) in a complex world — basic and digest authentication, redirections, cookies and more. See also The Requests package is recommended for...
python.library.urllib.request
class urllib.request.AbstractBasicAuthHandler(password_mgr=None) 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 HTTPPasswordMgr Objects for information on the inter...
python.library.urllib.request#urllib.request.AbstractBasicAuthHandler
AbstractBasicAuthHandler.http_error_auth_reqed(authreq, host, req, headers) Handle an authentication request by getting a user/password pair, and re-trying the request. authreq should be the name of the header where the information about the realm is included in the request, host specifies the URL and path to authent...
python.library.urllib.request#urllib.request.AbstractBasicAuthHandler.http_error_auth_reqed
class urllib.request.AbstractDigestAuthHandler(password_mgr=None) 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 HTTPPasswordMgr Objects for information on the inte...
python.library.urllib.request#urllib.request.AbstractDigestAuthHandler
AbstractDigestAuthHandler.http_error_auth_reqed(authreq, host, req, headers) authreq should be the name of the header where the information about the realm is included in the request, host should be the host to authenticate to, req should be the (failed) Request object, and headers should be the error headers.
python.library.urllib.request#urllib.request.AbstractDigestAuthHandler.http_error_auth_reqed
class urllib.request.BaseHandler This is the base class for all registered handlers — and handles only the simple mechanics of registration.
python.library.urllib.request#urllib.request.BaseHandler
BaseHandler.add_parent(director) Add a director as parent.
python.library.urllib.request#urllib.request.BaseHandler.add_parent
BaseHandler.close() Remove any parents.
python.library.urllib.request#urllib.request.BaseHandler.close
BaseHandler.default_open(req) This method is not defined in BaseHandler, but subclasses should define it if they want to catch all URLs. This method, if implemented, will be called by the parent OpenerDirector. It should return a file-like object as described in the return value of the open() of OpenerDirector, or No...
python.library.urllib.request#urllib.request.BaseHandler.default_open
BaseHandler.http_error_default(req, fp, code, msg, hdrs) This method is not defined in BaseHandler, but subclasses should override it if they intend to provide a catch-all for otherwise unhandled HTTP errors. It will be called automatically by the OpenerDirector getting the error, and should not normally be called in...
python.library.urllib.request#urllib.request.BaseHandler.http_error_default
BaseHandler.parent A valid OpenerDirector, which can be used to open using a different protocol, or handle errors.
python.library.urllib.request#urllib.request.BaseHandler.parent
BaseHandler.unknown_open(req) This method is not defined in BaseHandler, but subclasses should define it if they want to catch all URLs with no specific registered handler to open it. This method, if implemented, will be called by the parent OpenerDirector. Return values should be the same as for default_open().
python.library.urllib.request#urllib.request.BaseHandler.unknown_open
urllib.request.build_opener([handler, ...]) 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 clas...
python.library.urllib.request#urllib.request.build_opener
class urllib.request.CacheFTPHandler Open FTP URLs, keeping a cache of open FTP connections to minimize delays.
python.library.urllib.request#urllib.request.CacheFTPHandler
CacheFTPHandler.setMaxConns(m) Set maximum number of cached connections to m.
python.library.urllib.request#urllib.request.CacheFTPHandler.setMaxConns
CacheFTPHandler.setTimeout(t) Set timeout of connections to t seconds.
python.library.urllib.request#urllib.request.CacheFTPHandler.setTimeout
class urllib.request.DataHandler Open data URLs. New in version 3.4.
python.library.urllib.request#urllib.request.DataHandler
DataHandler.data_open(req) Read a data URL. This kind of URL contains the content encoded in the URL itself. The data URL syntax is specified in RFC 2397. This implementation ignores white spaces in base64 encoded data URLs so the URL may be wrapped in whatever source file it comes from. But even though some browsers...
python.library.urllib.request#urllib.request.DataHandler.data_open
class urllib.request.FancyURLopener(...) Deprecated since version 3.3. FancyURLopener subclasses URLopener providing default handling for the following HTTP response codes: 301, 302, 303, 307 and 401. For the 30x response codes listed above, the Location header is used to fetch the actual URL. For 401 response code...
python.library.urllib.request#urllib.request.FancyURLopener
prompt_user_passwd(host, realm) Return information needed to authenticate the user at the given host in the specified security realm. The return value should be a tuple, (user, password), which can be used for basic authentication. The implementation prompts for this information on the terminal; an application should...
python.library.urllib.request#urllib.request.FancyURLopener.prompt_user_passwd
class urllib.request.FileHandler Open local files.
python.library.urllib.request#urllib.request.FileHandler
FileHandler.file_open(req) Open the file locally, if there is no host name, or the host name is 'localhost'. Changed in version 3.2: This method is applicable only for local hostnames. When a remote hostname is given, an URLError is raised.
python.library.urllib.request#urllib.request.FileHandler.file_open
class urllib.request.FTPHandler Open FTP URLs.
python.library.urllib.request#urllib.request.FTPHandler
FTPHandler.ftp_open(req) Open the FTP file indicated by req. The login is always done with empty username and password.
python.library.urllib.request#urllib.request.FTPHandler.ftp_open
urllib.request.getproxies() This helper function returns a dictionary of scheme to proxy server URL mappings. It scans the environment for variables named <scheme>_proxy, in a case insensitive approach, for all operating systems first, and when it cannot find it, looks for proxy information from Mac OSX System Config...
python.library.urllib.request#urllib.request.getproxies
class urllib.request.HTTPBasicAuthHandler(password_mgr=None) Handle authentication with the remote host. password_mgr, if given, should be something that is compatible with HTTPPasswordMgr; refer to section HTTPPasswordMgr Objects for information on the interface that must be supported. HTTPBasicAuthHandler will rais...
python.library.urllib.request#urllib.request.HTTPBasicAuthHandler
HTTPBasicAuthHandler.http_error_401(req, fp, code, msg, hdrs) Retry the request with authentication information, if available.
python.library.urllib.request#urllib.request.HTTPBasicAuthHandler.http_error_401
class urllib.request.HTTPCookieProcessor(cookiejar=None) A class to handle HTTP Cookies.
python.library.urllib.request#urllib.request.HTTPCookieProcessor
HTTPCookieProcessor.cookiejar The http.cookiejar.CookieJar in which cookies are stored.
python.library.urllib.request#urllib.request.HTTPCookieProcessor.cookiejar
class urllib.request.HTTPDefaultErrorHandler A class which defines a default handler for HTTP error responses; all responses are turned into HTTPError exceptions.
python.library.urllib.request#urllib.request.HTTPDefaultErrorHandler
class urllib.request.HTTPDigestAuthHandler(password_mgr=None) Handle authentication with the remote host. password_mgr, if given, should be something that is compatible with HTTPPasswordMgr; refer to section HTTPPasswordMgr Objects for information on the interface that must be supported. When both Digest Authenticati...
python.library.urllib.request#urllib.request.HTTPDigestAuthHandler
HTTPDigestAuthHandler.http_error_401(req, fp, code, msg, hdrs) Retry the request with authentication information, if available.
python.library.urllib.request#urllib.request.HTTPDigestAuthHandler.http_error_401
class urllib.request.HTTPErrorProcessor Process HTTP error responses.
python.library.urllib.request#urllib.request.HTTPErrorProcessor
HTTPErrorProcessor.https_response(request, response) Process HTTPS error responses. The behavior is same as http_response().
python.library.urllib.request#urllib.request.HTTPErrorProcessor.https_response
HTTPErrorProcessor.http_response(request, response) Process HTTP error responses. For 200 error codes, the response object is returned immediately. For non-200 error codes, this simply passes the job on to the http_error_<type>() handler methods, via OpenerDirector.error(). Eventually, HTTPDefaultErrorHandler will ra...
python.library.urllib.request#urllib.request.HTTPErrorProcessor.http_response
class urllib.request.HTTPHandler A class to handle opening of HTTP URLs.
python.library.urllib.request#urllib.request.HTTPHandler
HTTPHandler.http_open(req) Send an HTTP request, which can be either GET or POST, depending on req.has_data().
python.library.urllib.request#urllib.request.HTTPHandler.http_open
class urllib.request.HTTPPasswordMgr Keep a database of (realm, uri) -> (user, password) mappings.
python.library.urllib.request#urllib.request.HTTPPasswordMgr
HTTPPasswordMgr.add_password(realm, uri, user, passwd) uri can be either a single URI, or a sequence of URIs. realm, user and passwd must be strings. This causes (user, passwd) to be used as authentication tokens when authentication for realm and a super-URI of any of the given URIs is given.
python.library.urllib.request#urllib.request.HTTPPasswordMgr.add_password
HTTPPasswordMgr.find_user_password(realm, authuri) Get user/password for given realm and URI, if any. This method will return (None, None) if there is no matching user/password. For HTTPPasswordMgrWithDefaultRealm objects, the realm None will be searched if the given realm has no matching user/password.
python.library.urllib.request#urllib.request.HTTPPasswordMgr.find_user_password
class urllib.request.HTTPPasswordMgrWithDefaultRealm 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.
python.library.urllib.request#urllib.request.HTTPPasswordMgrWithDefaultRealm
class urllib.request.HTTPPasswordMgrWithPriorAuth A variant of HTTPPasswordMgrWithDefaultRealm that also has a database of uri -> is_authenticated mappings. Can be used by a BasicAuth handler to determine when to send authentication credentials immediately instead of waiting for a 401 response first. New in version ...
python.library.urllib.request#urllib.request.HTTPPasswordMgrWithPriorAuth
HTTPPasswordMgrWithPriorAuth.add_password(realm, uri, user, passwd, is_authenticated=False) realm, uri, user, passwd are as for HTTPPasswordMgr.add_password(). is_authenticated sets the initial value of the is_authenticated flag for the given URI or list of URIs. If is_authenticated is specified as True, realm is ign...
python.library.urllib.request#urllib.request.HTTPPasswordMgrWithPriorAuth.add_password
HTTPPasswordMgrWithPriorAuth.find_user_password(realm, authuri) Same as for HTTPPasswordMgrWithDefaultRealm objects
python.library.urllib.request#urllib.request.HTTPPasswordMgrWithPriorAuth.find_user_password
HTTPPasswordMgrWithPriorAuth.is_authenticated(self, authuri) Returns the current state of the is_authenticated flag for the given URI.
python.library.urllib.request#urllib.request.HTTPPasswordMgrWithPriorAuth.is_authenticated
HTTPPasswordMgrWithPriorAuth.update_authenticated(self, uri, is_authenticated=False) Update the is_authenticated flag for the given uri or list of URIs.
python.library.urllib.request#urllib.request.HTTPPasswordMgrWithPriorAuth.update_authenticated
class urllib.request.HTTPRedirectHandler A class to handle redirections.
python.library.urllib.request#urllib.request.HTTPRedirectHandler
HTTPRedirectHandler.http_error_301(req, fp, code, msg, hdrs) Redirect to the Location: or URI: URL. This method is called by the parent OpenerDirector when getting an HTTP ‘moved permanently’ response.
python.library.urllib.request#urllib.request.HTTPRedirectHandler.http_error_301
HTTPRedirectHandler.http_error_302(req, fp, code, msg, hdrs) The same as http_error_301(), but called for the ‘found’ response.
python.library.urllib.request#urllib.request.HTTPRedirectHandler.http_error_302
HTTPRedirectHandler.http_error_303(req, fp, code, msg, hdrs) The same as http_error_301(), but called for the ‘see other’ response.
python.library.urllib.request#urllib.request.HTTPRedirectHandler.http_error_303
HTTPRedirectHandler.http_error_307(req, fp, code, msg, hdrs) The same as http_error_301(), but called for the ‘temporary redirect’ response.
python.library.urllib.request#urllib.request.HTTPRedirectHandler.http_error_307
HTTPRedirectHandler.redirect_request(req, fp, code, msg, hdrs, newurl) Return a Request or None in response to a redirect. This is called by the default implementations of the http_error_30*() methods when a redirection is received from the server. If a redirection should take place, return a new Request to allow htt...
python.library.urllib.request#urllib.request.HTTPRedirectHandler.redirect_request
class urllib.request.HTTPSHandler(debuglevel=0, context=None, check_hostname=None) A class to handle opening of HTTPS URLs. context and check_hostname have the same meaning as in http.client.HTTPSConnection. Changed in version 3.2: context and check_hostname were added.
python.library.urllib.request#urllib.request.HTTPSHandler
HTTPSHandler.https_open(req) Send an HTTPS request, which can be either GET or POST, depending on req.has_data().
python.library.urllib.request#urllib.request.HTTPSHandler.https_open
urllib.request.install_opener(opener) Install an OpenerDirector instance as the default global opener. Installing an opener is only necessary if you want urlopen to use that opener; otherwise, simply call OpenerDirector.open() instead of urlopen(). The code does not check for a real OpenerDirector, and any class with...
python.library.urllib.request#urllib.request.install_opener
class urllib.request.OpenerDirector The OpenerDirector class opens URLs via BaseHandlers chained together. It manages the chaining of handlers, and recovery from errors.
python.library.urllib.request#urllib.request.OpenerDirector
OpenerDirector.add_handler(handler) handler should be an instance of BaseHandler. The following methods are searched, and added to the possible chains (note that HTTP errors are a special case). Note that, in the following, protocol should be replaced with the actual protocol to handle, for example http_response() wo...
python.library.urllib.request#urllib.request.OpenerDirector.add_handler