- or download this
Perl & LWP
HTTP Connections In Perl
- or download this
What is HTTP?
...
Expires: Fri, 04 Feb 2005 00:43:02 GMT
...
<html>
- or download this
LWP is easy to use
...
} else {
print $response->status_line, " <URL:$url>\n";
}
- or download this
LWP::Simple is even easier
...
use LWP::Simple;
getprint('http://www.cnet.com/bogus/');
- or download this
First, a Perl refresher
...
if ($bar->[1]) { # "if" and "print" work the way you t
+hink
print "$first is true\n"; # Double quotes evaluate variables
} # ... prints: Hoss is true
- or download this
More fun with LWP::Simple
...
my ($type, $length, $mod, $exp, $server) = head('http://news.com');
print "Content Type is $type, and the Server is $server\n";
- or download this
LWP::UserAgent is more "full featured"
...
{'descr' => 'your bug description',
'component' => 'your bug component',
'priority' => 'P1' });
- or download this
HTTP::Request & HTTP::Response
...
while ($res = $res->previous()) {
print "Redirected from: ", $res->request()->uri(), "\n";
}
- or download this
Previous script's output
...
The URL was: http://builder.com.com/
Redirected from: http://builder.cnet.com/webbuilding/pages/foo
Redirected from: http://builder.com/foo
- or download this
Other cool features worth looking at
...
* Read/write cookies from disk (in Mozilla or Microsoft formats)
* Parse/Submit forms auto-magically
* LWP:RobotUA, LWP::Parallel::UserAgent, LWP::UserAgent::FramesReady
- or download this
One caveat to LWP::Simple
...
my $data = get('http://cnet.com/bogus/');
# http://www.perlmonks.org/?node=412544
- or download this
More Info
...
http://search.cpan.org/search?query=LWP
http://search.cpan.org/dist/WWW-Mechanize/