----- Original Message -----
From: "Gerald Preston" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, April 07, 2006 11:18 PM
Subject: first time using LWP
Hi!
Not sure where to begin, although I have been reading every thing I can
find, but I am looking for a few good examples that use LWP to read web
pages from a Perl script that runs from WIN XP DOS command line.
Try this:
#!/usr/bin/perl
use strict;
use LWP::UserAgent;
require HTTP::Headers;
my $content = readweb('http://www.google.com');
print $content;
sub readweb {
my $url=shift;
my $ua = LWP::UserAgent->new(timeout => 600);
my $myagent='Mozilla/4.0 (compatible; My_reader; Linux)';
$ua->agent($myagent);
my $req = new HTTP::Request GET => $url;
$req->headers->header(Accept => "text/html, text/plain, image/*, */*");
$req->headers->header(Connection => "Keep-Alive");
my $res = $ua->request($req);
if ($res->is_error*1 > 0) {
return ($res->code);
}
return $res->content;
}
Petr Vileta, Czech republic
(My server reject all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs