- 论坛徽章:
- 0
|
在用lwp请求一个网页
my $ua = LWP::UserAgent->new;
$ua->agent("Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0. Gecko/2009032711 Ubuntu/8.04 (hardy) Firefox/3.0.8");
print "requesting ..... $url\n";
my $req = HTTP::Request->new(GET => $url);
$req->content_type('application/x-www-form-urlencoded');
$req->content('query=libwww-perl&mode=dist');
|
请求的后提示错误:
411 Length Required
我加了这一句, 随便设置了下length:
$req->content_length('2387'); |
报错多了一句:
Content-Length header value was wrong, fixed at /usr/share/perl5/LWP/Protocol/http.pm line 186.
我只是客户端请求一个url,又不是应答
怎么还要浏览器的content-length呢? |
|