Okay here's some example code for the first part, but alas, I'm not too sure
about the second:
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
$ua->agent("$0/0.1 " . $ua->agent);
# $ua->agent("Mozilla/8.0") # pretend we are very capable browser
$file = "test.txt";
$url = "http://www.slashdot.org";
open OUTPUT, ">$file" or die ("Could not open $file for writing: $!\n");
$req = HTTP::Request->new(GET => $url);
# send request
$res = $ua->request($req);
# check the outcome
if ($res->is_success) {
print OUTPUT $res->content;
} else {
print "Error: " . $res->status_line . "\n";
}
close OUTPUT;
that's it.
>From: Rob McMillin <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: How to write output of a GET request to disk?
>Date: Sat, 09 Sep 2000 11:16:38 -0700
>
>I've been reading the docs for the libwww code, and was wondering if
>there is any way to write the output of a request directly to a file on
>disk. The returned data could be potentially quite large and shouldn't
>be stored in memory.
>
>Also, I would like to know if there is a way to just read headers and
>ignore the rest of the data based on the value of the returned headers.
>The motivation is to avoid downloading files in cases where the
>timestamp hasn't changed.
>
>--
> http://www.pricegrabber.com | Dog is my co-pilot.
>
>
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Share information about yourself, create your own public profile at
http://profiles.msn.com.