<pre name="code" class="html"><body class="api jquery listing"> <div id="container"> <div id="content-wrapper" class="clearfix row"> <div class="content-right twelve columns"> <div id="content"> <div class="container fl"> <h1 class="title">产品公告查询接口管理</h1> <!-- api start --> <h2 class="subtitle" id="getInfo">查询产品公告详情</h2> 根据body的内容 查找h2标签的@class="subtitle"的值 jrhmpt01:/root# cat yy1.pl use LWP::UserAgent; use DBI; use POSIX; use Data::Dumper; use HTML::TreeBuilder; my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->env_proxy; $ua->agent("Mozilla/8.0"); use HTML::TreeBuilder::XPath; $tree= HTML::TreeBuilder::XPath->new; $tree->parse_file( "ProductForcastController.html"); my @title= $tree->findvalues('/html/body//h2[@class="subtitle"]'); print "@title is @title " jrhmpt01:/root# perl yy1.pl @title is 查询产品公告详情 查询产品公告