为什么WWW::Mechanize
在获得以下URL后有空白内容?使用浏览器或curl
检索完整的HTML页面。为什么WWW :: Mechanize失败,出现“X-Died:Illegal field name”X-Meta-Twitter:title'“?
use WWW::Mechanize;
$mech = new WWW::Mechanize;
$mech->get("http://www.belizejudiciary.org/web/judgements2/");
print $mech->content # prints nothing
这里是响应的转储:
HTTP/1.1 200 OK
Connection: close
Date: Fri, 10 Feb 2017 00:51:47 GMT
Server: Apache/2.4
Content-Type: text/html; charset=UTF-8
Client-Aborted: die
Client-Date: Fri, 10 Feb 2017 00:51:48 GMT
Client-Peer: 98.129.229.64:80
Client-Response-Num: 1
Client-Transfer-Encoding: chunked
Link: <http://www.belizejudiciary.org/web/wp-json/>; rel="https://api.w.org/"
Link: <http://www.belizejudiciary.org/web/?p=468>; rel=shortlink
Set-Cookie: X-Mapping-hepadkon=FAB86566672CEB74D66B2818CA030616; path=/
X-Died: Illegal field name 'X-Meta-Twitter:title' at /usr/local/lib/perl5/site_perl/5.16.3/sun4-solaris/HTML/HeadParser.pm line 207.
X-Pingback: http://www.belizejudiciary.org/web/xmlrpc.php
我有HTML 3.70版本::分析器安装。
我没有得到任何东西。你使用什么版本的模块? '使用Data :: Dumper的内容是什么;打印Dumper($ mech-> response)'? – choroba
@choroba我的系统有3.70版本的HTML:Parser,所以这可能是一个问题。查看我的编辑回复。 – CJ7
@choroba在'get'解决问题之前添加'$ mech-> parse_head(0)'。从这个答案:http://stackoverflow.com/a/17745491/327528 – CJ7