468,304 Members | 1,447 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,304 developers. It's quick & easy.

downloading web images

Joe
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
Oct 23 '05 #1
2 1190
Hi !

Note :
urllib2.urlopen is more fast and more "modern"
open("myfile.jpg", "wb") if better for binary

Have a good day.

MCI


Oct 23 '05 #2
On Sun, 23 Oct 2005 06:52:26 +0000, Joe wrote:
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.


What do you mean that the file does not appear to be an image? If it works
fine and you can open the image, then what is the problem?
--
Steven.

Oct 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Marc | last post: by
23 posts views Thread by Doug van Vianen | last post: by
3 posts views Thread by xeroxero | last post: by
1 post views Thread by Hans Olav Hygen | last post: by
5 posts views Thread by OBAFGKM_RNS | last post: by
6 posts views Thread by dysfunct | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by Teichintx | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.