Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

How can a perl script take an image URL like http://perlmonks.org/images/monasterygatestitle2.jpg grab the data and save it to a file?

Replies are listed 'Best First'.
(kudra) Re: Pulling an image
by kudra (Vicar) on Dec 03, 2000 at 20:21 UTC
    You might try the Image::Grab module, which was suggested by merlyn in this thread. If you plan to use this as a way to get site content and avoid advertisements, keep in mind that some sites may not appreciate that. You might want to read Yohimbe's comments in the same thread. I think it's come up another time as well, but I can't remember any keywords for it.
Re: Pulling an image
by mirod (Canon) on Dec 03, 2000 at 20:29 UTC

    The easiest is probably to do:

    use LWP::Simple; getstore ' http://perlmonks.org/images/monasterygatestitle2.jpg', 'monasterygatestitle2.jpg ';

    And you can do perldoc lwpcook for more info

      Rather than using getstore, if you're always gonna be dropping it into the same file, use mirror (same syntax). This permits the webserver to reply with a "304 error" and no data transfer if you've already got the most up-to-date version of the file, and also sets the modtime of the file to the "last-modified" header so you have a clue as to the document's age.

      -- Randal L. Schwartz, Perl hacker