in python the urllib functionality is spread across several different library modules including urlliburllib urlparseand robotparser in python all of this functionality has been consolidated and reorganized under the urllib package urllib request (urllib the urllib request module provides functions and classes to open and fetch data from urls in python this functionality is found in module urllib the most common use of this module is to fetch data from web servers using http for examplethis code shows the easiest way to simply fetch web pagetryfrom urllib request import urlopen except importerrorfrom urllib import urlopen python python urlopen("data read(of coursemany complexities arise when interacting with servers in the real world for exampleyou might have to worry about proxy serversauthenticationcookiesuser agentsand other matters all of these are supportedbut the code is more complicated (keep readingurlopen(and requests the most straightforward way to make request is to use the urlopen(function urlopen(url [data [timeout]]opens the url url and returns file-like object that can be used to read the returned data url may either be string containing url or an instance of the request classdescribed shortly data is url-encoded string containing form data to be uploaded to the server when suppliedthe http 'postmethod is used instead of 'get(the defaultdata is generally created using function such as urllib parse urlencode(timeout is an optional timeout in seconds for all blocking operations used internally the file-like object returned by urlopen(supports the following methodsmethod description read([nbytes] readline( readlines( fileno( close( info(reads nbytes of data as byte string reads single line of text as byte string reads all input lines and returns list returns the integer file descriptor closes the connection returns mapping object with meta-information associated with the url for httpthe http headers included with the server response are returned for ftpthe headers include 'content-lengthfor local filesthe headers include date'content-length'and 'content-typefield returns the http response code as an integer--for example for success or for file not found returns the real url of the returned datataking into account any redirection that may have occurred getcode( geturl( lib fl ff