Retrieve a webpage using LWP in Perl

#!/usr/bin/perl -w
use LWP;
use strict;
my $browser = LWP::UserAgent->new(agent => 'Mozilla Firefox 3.2');
my $result = $browser->get("http://www.w3mentor.com");
die "An error occurred: ", $result->status_line( ) unless \
$result->is_success;
#Do something more meaningful with the content than this!
print $result->content;

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.