jrhmpt01:/root/lwp/0526# cat a1.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( "0526.txt"); my @pages=$tree->find_by_tag_name('input'); #@urlall除了包含每个类别的文章,还包含阅读排行里的文章 foreach (@pages) { @titlepage = $_->attr('value'); foreach (@titlepage) { if ($_){ print "$_ is $_ "; }; }; }; jrhmpt01:/root/lwp/0526# cat 0526.txt <input name="csrfmleawretoken" type="hidden" value="fs34fgsdfsdfsdfsfsfs"/> <input name="csrfmleawretoken" type="hidden" value="scan3131313"/> jrhmpt01:/root/lwp/0526# perl a1.pl $_ is fs34fgsdfsdfsdfsfsfs $_ is scan3131313