爲什麼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