Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

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:

Hi

Task : To download content from web and store in directory

Usage : script URL destination_directory Example : perl script "http://www.perl.org/i/camel_head.png" /tmp

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

Appreciate help from the monks

Thanks

Kunal

Comment on Perl script to download web content
Download Code
Re: Perl script to download web content
by marto (Chancellor) 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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://871040]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2014-09-20 06:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (155 votes), past polls