Weiyan
Weiyan

Reputation: 1116

LWP::UserAgent post method not return value

Just copy this code from perl cook book 2nd ed pp. 796

it returns: 400 URL must be absolute.

What's wrong with this code?

#!"c:\strawberry\perl\bin\perl.exe" -w

use 5.006;
use strict;
use LWP::Simple;
use LWP::UserAgent;

my $ua = LWP::UserAgent->new();
my $resp = $ua->post("www.amazon.com/exec/obidos/search-handle-form",
                     { "url"             => "index-books",
                       "field-keywords"  => "perl"}
);
my $content = $resp->content;

print $content, "\n";

Upvotes: 1

Views: 2830

Answers (1)

Quentin
Quentin

Reputation: 944301

You forgot the http:// on the front of the URL

Well, presumably http://, it might be https://, ftp://, etc, etc.

Upvotes: 7

Related Questions