Wednesday, August 6, 2014

How To Download The Web Page Data In Python

How To Download / Get The Web Page Data In Python


Let' consider you wish to download the whole contents of a web page: http://www.pythonchallenge.com/pc/def/banner.p


All you need to is use urllib module in Python.

import urllib
handle = urllib.urlopen("http://www.pythonchallenge.com/pc/def/banner.p")
print handle.read()

#You can also write the contents to the file
f1 = open("temp_data","w")
f1.write(handle.read())
f1.close()






No comments:

Post a Comment