【发布时间】:2017-02-10 00:35:17
【问题描述】:
为什么WWW::Mechanize得到以下网址后内容为空白?使用浏览器或curl 检索到完整的 HTML 页面。
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
我安装了 3.70 版的 HTML::Parser。
【问题讨论】:
-
我什么也没得到。您使用什么版本的模块?
use Data::Dumper; print Dumper($mech->response)的内容是什么? -
@choroba 我的系统有
HTML:Parser的3.70 版,所以这可能是个问题。请参阅我的编辑以获取回复。 -
@choroba 在
get之前添加get解决了问题。从这个答案:stackoverflow.com/a/17745491/327528 -
我觉得这是您找到的that other SO question 的副本,但这些答案都有待改进。我的意思是,猴子修补 HTML::HeadParser?完全禁用标头解析?真的吗?
-
@ThisSuitIsBlackNot 我认为这是将问题标记为重复的问题。
标签: perl curl www-mechanize