Learn Perl: Perl Q&A: What's the easiest way to download the contens of a URL with Perl?
Developer's Daily Perl Q&A Center
  main | java | perl | unix | dev directory | web log
   
Main
Perl
Education
Perl Q&A


Question: What is the easiest way to download the contents of a URL with Perl?

Answer:

The easiest way I know to download the contents on a URL (i.e., "http://...") is to use the libwww-perl library, LWP.pm.

Once you have that module installed, the easiest code is this:


   #!/usr/bin/perl

   use LWP::Simple;
   $url = get 'http://www.DevDaily.com/';

At this point the variable $url contains the contents of the URL you specified. From here you can print the URL, or otherwise manipulate it in your program.

For many other options, see the LWP.pm module and lwpcook.pod documentation!

 

Copyright © 1998 DevDaily Interactive, Inc.
All Rights Reserved.