开发者

What is the reason for the error message `Can't locate object method "get_ok"` when using WWW::Mechanize::TreeBuilder?

开发者 https://www.devze.com 2023-02-09 11:22 出处:网络
I couldn\'t really figure out how to use WWW::Mechanize::TreeBuilder. Basically I get a HTML page using WWW::Mechanize. There is a //div[@class=\'cars\'] whose text I want to extract.

I couldn't really figure out how to use WWW::Mechanize::TreeBuilder. Basically I get a HTML page using WWW::Mechanize. There is a //div[@class='cars'] whose text I want to extract.

I tried:

my $mech = WWW::Mechanize->new();
$mech->get('the url');
WWW::Mechanize::TreeBuilder->meta开发者_JS百科->apply($mech);
$mech->get_ok('//div[@class="cars"]');
print $mech->look_down(_tag => 'p')->as_trimmed_text . "\n";

It says:

Can't locate object method "get_ok" via package "Class::MOP::Class::__ANON__::SERIAL::2" at orpi_crawler.pl


get_ok is from Test::WWW::Mechanize which you neglected to load. Read the synopsis of WWW::Mechanize::TreeBuilder carefully.

0

精彩评论

暂无评论...
验证码 换一张
取 消