无法调用方法" text"在sample.pl第11行

时间:2016-01-11 05:07:36

标签: perl html-parsing perl-module mojolicious mojo

use strict;    # safety net
use warnings;  # safety net
use feature 'say'; # a better "print"

use Mojo;
my $dom = Mojo::DOM->new;
my $ua = Mojo::UserAgent->new;
$dom= $ua->get('http://search.cpan.org/faq.html')->res->dom;
my $desc=$dom->at('#u')->text;

当我运行此代码时,出现上述错误。这是我在网页后面的输入数据表格请参阅 this

我希望这样的输出只能回答。

   CPAN Search is a search engine for the distributions, modules, docs, and ID's on CPAN. It was conceived and built by Graham Barr as a way to make things easier to navigate. Originally named TUCS [ The Ultimate CPAN Search ] it was later named CPAN Search or Search DOT CPAN.

   If you are having technical difficulties with the site itself, send mail to cpansearch@perl.org and try to be as detailed as possible in your note describing the problem.

请任何人都可以帮助我

1 个答案:

答案 0 :(得分:1)

这样的事情:

perl -Mojo -le 'print r g("http://search.cpan.org/faq.html")->dom("#cpansearch > div.pod > p")->map("text")->to_array;'