internet application programming it is important to emphasize that the file-like object operates in binary mode if you need to process the response data as textyou will need to decode it using the codecs module or some other means if an error occurs during downloadan urlerror exception is raised this includes errors related to the http protocol itself such as forbidden access or requests for authentication for these kinds of errorsa server typically returns content that gives more descriptive information to get this contentthe exception instance itself operates as file-like object that can be read for exampletryu urlopen("resp read(except httperror as eresp read( very common error that arises with urlopen(is accessing web pages through proxy server for exampleif your organization routes all web traffic through proxyrequests may fail if the proxy server doesn' require any kind of authenticationyou may be able to fix this by merely setting the http_proxy environment variable in the os environ dictionary for exampleos environ['http_proxy''for simple requeststhe url parameter to urlopen(is string such as 'make modifications to http request headerscreate request instance and use that as the url parameter request(url [data [headers [origin_req_host [unverifiable]]]]creates new request instance url specifies the url (for example'the server in http requests when this is suppliedit changes the http request type from 'getto 'postheaders is dictionary containing key-value mappings representing the contents of the http headers origin_req_host is set to the request-host of the transaction--typically it' the host name from which the request is originating unverifiable is set to true if the request is for an unverifiable url an unverifiable url is informally defined as url not directly entered by the user--for instancea url embedded within page that loads an image the default value of unverifiable is false an instance of request has the following methodsr add_data(dataadds data to request if the request is an http requestthe method is changed to 'postdata is url-encoded data as described for request(this does not append data to any previously set datait simply replaces the old data with data add_header(keyvaladds header information to the request key is the header nameand val is the header value both arguments are strings lib fl ff