Newbie: How to download a JPG file from the internet....?
dietmar at nospam.wohnheim.fh-wedel.de
Mon Sep 17 22:49:58 CEST 2001
> Can anyone tell me how to download an image from a web site?
> An example:
><IMG SRC="./images/getme.jpg"> that is located at www.somewhere.org
> I have already found the urllib module and have used the urlopen
> function to create a string from a web page, but I don't know how to
> proceed from here. I can isolate the string - <IMG
> SRC="./images/getme.jpg">, but then what? I would like to eventually write
> it to a file on my local drive. Any information will be greatly
> appreciated. Thank you for your time.
Well, I did something like this a couple days ago:
## begin code
url = 'http://www.somewhere.org/images/getme.jpg'
filename = 'getme.jpg' # coerce the name from your string
image = urllib.URLopener()
## end code
Something in that order will do the trick. At least it does for me every
day, downloading the latest comic strips from the web. ;)
To mail me, remove "nospam.".
More information about the Python-list