Open a URL and read a web page : URL « Network « Python






Open a URL and read a web page

 

import urllib
pagehandler = urllib.urlopen("http://www.google.com")
outputfile = open("index.html", "wb")
while 1:
    data = pagehandler.read(512)
    if not data:
        break
    outputfile.write(data)
outputfile.close()
pagehandler.close()

   
  








Related examples in the same category

1.Split up a URL of the form http://www.something.com
2.URL joinURL join
3.URL SplitURL Split
4.URL unsplitURL unsplit
5.URL unsplit and splitURL unsplit and split
6.URL open and read