T
Tim Jowers
Advice? I get this error message:
C:\houses\scraper>perl test2.pl
Can't locate object method "default_headers" via package
"LWP::UserAgent" at tes
t2.pl line 11.
But downloaded the latest libwww-perl-5.801 and copied the files from
/bin and /lib into my Perl install. Why does not this work?
default_headers are a new method added this year according to the post
http://groups.google.com/[email protected]&rnum=2
Here's my program. It's a test program as referrer must be set in the
real program.
# Create a user agent object
use LWP::UserAgent;
$ua = LWP::UserAgent->new(default_headers);
$ua->agent("MyApp/0.1 ");
# Create a request
my $req = HTTP::Request->new(POST =>
'http://search.cpan.org/search');
$req->content_type('application/x-www-form-urlencoded');
$req->content('query=libwww-perl&mode=dist');
my $h = $ua->default_headers;
$h->header('Referer' => shift);
# Pass request to the user agent and get a response back
my $res = $ua->request($req);
# Check the outcome of the response
if ($res->is_success) {
print $res->content;
}
else {
print $res->status_line, "\n";
}
TIA,
TimJowers
C:\houses\scraper>perl test2.pl
Can't locate object method "default_headers" via package
"LWP::UserAgent" at tes
t2.pl line 11.
But downloaded the latest libwww-perl-5.801 and copied the files from
/bin and /lib into my Perl install. Why does not this work?
default_headers are a new method added this year according to the post
http://groups.google.com/[email protected]&rnum=2
Here's my program. It's a test program as referrer must be set in the
real program.
# Create a user agent object
use LWP::UserAgent;
$ua = LWP::UserAgent->new(default_headers);
$ua->agent("MyApp/0.1 ");
# Create a request
my $req = HTTP::Request->new(POST =>
'http://search.cpan.org/search');
$req->content_type('application/x-www-form-urlencoded');
$req->content('query=libwww-perl&mode=dist');
my $h = $ua->default_headers;
$h->header('Referer' => shift);
# Pass request to the user agent and get a response back
my $res = $ua->request($req);
# Check the outcome of the response
if ($res->is_success) {
print $res->content;
}
else {
print $res->status_line, "\n";
}
TIA,
TimJowers