Re: Saving a picture contained in a web page to disk
From: Michael Geary (Mike_at_DeleteThis.Geary.com)
Date: 11/13/03
- Next message: Georgy Pruss: "Re: Am I the only one who would love these extentions? - Python3.0proposals (long)"
- Previous message: DD: "Access sql with python, please. I'm desperate"
- In reply to: Giulio Cespuglio: "Saving a picture contained in a web page to disk"
- Next in thread: Michael Geary: "Re: Saving a picture contained in a web page to disk"
- Reply: Michael Geary: "Re: Saving a picture contained in a web page to disk"
- Reply: John Hunter: "Re: Saving a picture contained in a web page to disk"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 12 Nov 2003 15:09:50 -0800
Giulio Cespuglio:
> I would like to save to disk a picture contained in a webpage.
>
> Unfortunately the image is dynamic, so the url is actually a query
> which looks like
>
> http://adfarm.mediaplex.com/ad/bn/2397-11787-1843-5?mpt=1068644406357385
>
> rather than the standard
>
> http://img-cdn.mediaplex.com/ads/2397/11787/q2_dell_inspiron_120x600.gif
That doesn't matter at all.
> I've been told that a scripting language like Perl, Python or PHP is
> my best bet for this kind of tasks, would you agree?
Absolutely! :-)
> Could you please give a few function names to look at as a starting
> point?
> That should suffice, although a code snippet would be greatly
> appreciated.
Try running this code and see what you think:
#########################
import urllib
def saveUrlToFile( url, fileName ):
f = open( fileName, 'wb' )
data = urllib.urlopen(url).read()
f.write( data )
f.close()
saveUrlToFile(
'http://adfarm.mediaplex.com/ad/bn/2397-11787-1843-5?mpt=1068644406357385',
'test.gif' )
#########################
-Mike
- Next message: Georgy Pruss: "Re: Am I the only one who would love these extentions? - Python3.0proposals (long)"
- Previous message: DD: "Access sql with python, please. I'm desperate"
- In reply to: Giulio Cespuglio: "Saving a picture contained in a web page to disk"
- Next in thread: Michael Geary: "Re: Saving a picture contained in a web page to disk"
- Reply: Michael Geary: "Re: Saving a picture contained in a web page to disk"
- Reply: John Hunter: "Re: Saving a picture contained in a web page to disk"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|