perl HTML::HeadParser获取html头部信息
1 use LWP::Simple; 2 use HTML::HeadParser; 3 use utf8; 4 binmode(STDOUT, ":encoding(gbk)"); #设置win下输出中文 5 6 $result = get('http://www.baidu.com'); 7 $what = HTML::HeadParser->new; 8 $what->parse($result); 9 print $what->header('refresh'),"\n"; 10 print $what->header('title'),"\n"; 11 print $what->header('content_type'),"\n";