Newbie: How to download a JPG file from the internet....?

Dietmar Lang dietmar at
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
>     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

import urllib

url = ''

filename = 'getme.jpg' # coerce the name from your string

image = urllib.URLopener()
image.retrieve(url, filename())

## 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. ;)

Kudos, Dietmar

To mail me, remove "nospam.".

More information about the Python-list mailing list