networked programs running out of memorywe retrieve the data in blocks (or buffersand then write each block to your disk before retrieving the next block this way the program can read any size file without using up all of the memory you have in your computer import urllib requesturllib parseurllib error img urllib request urlopen('fhand open('cover jpg''wb'size while trueinfo img read( if len(info break size size len(infofhand write(infoprint(size'characters copied 'fhand close(codein this examplewe read only , characters at time and then write those characters to the cover jpg file before retrieving the next , characters of data from the web this program runs as followspython curl py characters copied parsing html and scraping the web one of the common uses of the urllib capability in python is to scrape the web web scraping is when we write program that pretends to be web browser and retrieves pagesthen examines the data in those pages looking for patterns as an examplea search engine such as google will look at the source of one web page and extract the links to other pages and retrieve those pagesextracting linksand so on using this techniquegoogle spiders its way through nearly all of the pages on the web google also uses the frequency of links from pages it finds to particular page as one measure of how "importanta page is and how high the page should appear in its search results parsing html using regular expressions one simple way to parse html is to use regular expressions to repeatedly search for and extract substrings that match particular pattern here is simple web page