正如标题所说WWW ::机械化不承认WWW ::机械化忽略了gzip压缩的内容基本href
<base href="" />
如果页面内容IZ gzip压缩。这里有一个例子:
use strict;
use warnings;
use WWW::Mechanize;
my $url = 'http://objectmix.com/perl/356181-help-lwp-log-after-redirect.html';
my $mech = WWW::Mechanize->new;
$mech->get($url);
print $mech->base()."\n";
# force plain text instead of gzipped content
$mech->get($url, 'Accept-Encoding' => 'identity');
print $mech->base()."\n";
输出:
http://objectmix.com/perl/356181-help-lwp-log-after-redirect.html
http://objectmix.com/ <--- this is correct !
我在这里失去了一些东西?由于
编辑:我刚刚与LWP :: UserAgent的测试,它直接和它的作品没有任何问题:
use LWP::UserAgent;
my $ua = LWP::UserAgent->new();
my $res = $ua->get('http://objectmix.com/perl/356181-help-lwp-log-after-redirect.html');
print $res->base()."\n";
输出:
http://objectmix.com/
这看起来像WWW ::机械化的错误?
编辑2: 它是LWP或HTTP ::响应错误,而不是WWW :: Mechanize。 LWP默认不会请求gzip。如果我在上面的例子中设定
$ua->default_header('Accept-Encoding' => 'gzip'),
它返回错基
编辑3:在parse_head 错误是在LWP/UserAgent.pm()
它调用的HTML/HeadParser与gzip HTML和HeadParser不知道该如何处理它。 LWP应该在调用解析子例程之前对内容进行压缩。
它不能是一个功能,如果它没有返回相同的结果上gzipped和非gzipped内容。如果base不是http://objectmix.com/,那么没有任何相关链接可以工作。 – toktok 2012-03-09 09:41:41