Wednesday 28 December 2016

What is urllib.request module?


urllib.request module consists of  functions and classes which help in opening URL's.

It has got following methods:
1. urllib.request.urlopen(url, data=None, [timeout, ]*, cafile=None, capath=None, cadefault=False, context=None)
 url : name of the url,It can be a string or Request object.
urllib.request module uses HTTP/1.1 and includes Connection:close header in its HTTP requests.
 timeout:is timeout in seconds for blocking operations.If  it is not set default timeout will be considered.
The cafile and capath parameters are optional, specify  CA certificates for HTTPS requests. cafile should point to a single file containing a bundle of CA certificates, whereas capath should point to a directory of hashed certificate files.
The cadefault parameter is ignored.

2.urllib.request.install_opener(opener)






















Note:This is according to  versions Python 3 and above.