【发布时间】:2015-09-03 08:28:07
【问题描述】:
我是 Mojolicious 的新手。我确信这可能是一个设置问题,但它占用了我一整天的时间。我正在尝试运行这个简单的测试代码
#!/usr/bin/perl
use strict;
use warnings;
use Mojo::DOM;
use Mojo::UserAgent;
my $ua = Mojo::UserAgent->new();
$ua->get('https://stackoverflow.com/questions/26353298/find-links-containing-bold-text-using-wwwmechanize')->res->dom('a div')->ancestors('div.spacer')->each( sub { say $_->all_text } );
我在这个位置找到的
find links containing bold text using WWW::Mechanize
它失败了
Can't locate object method "ancestors" via package "Mojo::Collection" at ./test4.pl line 10.
我已经卸载并重新安装了无数次,尝试了不同的软件包安装选项(cpan、cpanm、直接链接等)。没有骰子。我有点困惑 Mojo::Collection 模块中似乎没有“祖先”方法(继承或没有),但我见过其他几个类似的例子,它们似乎以相同的方式使用相同的方法.不仅仅是“祖先”模块——问题似乎也影响了其他一些方法。
我在 Linux Mint 上使用 perl 5.18.2 和 Mojolicious 包 6.11。
感谢您的帮助。
【问题讨论】:
标签: perl dom mojolicious mojo