python' standard library (the modules that are installed with the interpreteralso includes client-side support for http--the hypertext transfer protocol-- message structure and port standard used to transfer information on the world wide web in shortthis is the protocol that your web browser ( internet explorerfirefoxchromeor safariuses to fetch web pages and run applications on remote servers as you surf the web essentiallyit' just bytes sent over port to really understand http-style transfersyou need to know some of the server-side scripting topics covered in ( script invocations and internet address schemes)so this section may be less useful to readers with no such background luckilythoughthe basic http interfaces in python are simple enough for cursory understanding even at this point in the bookso let' take brief look here python' standard http client module automates much of the protocol defined by http and allows scripts to fetch web pages as clients much like web browsersas we'll see in http server also allows us to implement web servers to handle the other side of the dialog for instancethe script in example - can be used to grab any file from any server machine running an http web server program as usualthe file (and descriptive header linesis ultimately transferred as formatted messages over standard socket portbut most of the complexity is hidden by the http client module (see our raw socket dialog with port http server in for comparisonexample - pp \internet\other\http-getfile py ""fetch file from an http (webserver over sockets via http clientthe filename parameter may have full directory pathand may name cgi script with query parameters on the end to invoke remote programfetched file data or remote program output could be saved to local file to mimic ftpor parsed with str find or html parser modulealsohttp client request(methodurlbody=nonehdrs={})""import syshttp client showlines tryservernamefilename sys argv[ :cmdline argsexceptservernamefilename 'learning-python com''/index htmlprint(servernamefilenameserver http client httpconnection(servernameserver putrequest('get'filenameserver putheader('accept''text/html'server endheaders(connect to http site/server send request and headers post requests work here too as do cgi script filenames reply server getresponse(read reply headers data if reply status ! means success print('error sending request'reply statusreply reasonelse client-side scripting