downloading web images

Joe dinamo99 at lycos.com
Sun Oct 23 02:52:26 EDT 2005


I'm just wandering if I'm doing this correct way I'm trying to download an
image and store it into a file this does the job, but created file does not
apear to be an image, it works fine and I can open image, I'm just
wandering if there is a better way of doing this. 

htmlSource=urllib.urlopen("http://www.godandscience.org/images/nebula.jpg")
# Read from the object, storing the page's contents in 's'.
s = htmlSource.read()
htmlSource.close()
myfile = open("myfile.jpg", "w")
myfile.write(s)
myfile.close

Thanks



More information about the Python-list mailing list