Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Perl script to download web content

by quipper (Initiate)
on Nov 12, 2010 at 12:18 UTC ( #871040=perlquestion: print w/replies, xml ) Need Help??
quipper has asked for the wisdom of the Perl Monks concerning the following question:


Task : To download content from web and store in directory

Usage : script URL destination_directory Example : perl script "" /tmp

This should save the camel_head.png file into /tmpdirectory.

Appreciate help from the monks



Replies are listed 'Best First'.
Re: Perl script to download web content
by marto (Bishop) on Nov 12, 2010 at 12:21 UTC
Re: Perl script to download web content
by bart (Canon) on Nov 12, 2010 at 12:34 UTC
    I assume that this is a homework problem, and that it's not the intention to just use an existing script, even if it comes straight from CPAN.

    In that case, you can still make use of a module, because that's what you ought to do when doing this for a real script, so I suggest you take a good looks at LWP::Simple, in particular the subs get and getstore.

Re: Perl script to download web content
by AR (Friar) on Nov 12, 2010 at 14:15 UTC
    Can you use wget?

      Dear Monks , Thanks for your response

      Marto - using lwp-download fixes my problem

      Bart - Yes this is a homework problem , i can now use it in my script

        If you're simply going to submit the script as your own work, you've missed the point of your homework.

Re: Perl script to download web content
by pemungkah (Priest) on Nov 16, 2010 at 02:53 UTC
    Hi, quipper - regardless of whether lwp-download as a component is acceptable, I'd like to suggest that you look through it (and maybe even through LWP) as a learning experience. If you later chance across a similar problem that lwp-download won't cut it for (say, logging in to a password-protected website that needs a cookie for access), knowing what the basic operations are might be really helpful.

    I'd personally have used WWW::Mechanize and written it as a one-liner - just about as short as using lwp-download but easier to adapt if necessary.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://871040]
Approved by marto
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2018-03-25 00:20 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (299 votes). Check out past polls.