1
当我运行此代码时,我得到以下输出
允许您使用罗马数字编写Perl 6代码:
但我希望输出为:
perl6-slang-roman允许您使用罗马数字编写Perl 6代码:
任何人都可以帮助我吗?
答案 0 :(得分:2)
text
方法只会在节点内立即获取文本节点。要获取所有后代文本节点,您需要使用all_text
再次使用join
然后split
将元素分成列表也相当丑陋。 find
方法返回一个Mojo::Collection
对象,可以直接编入索引
将所选的div
限制为具有所需类别的
喜欢这个
use strict;
use warnings;
use feature 'say';
use Mojo;
my $ua = Mojo::UserAgent->new;
my $collection = $ua->get('http://blogs.perl.org/')->res->dom->find('div.entry-body > p ');
say $collection->[0]->all_text;
perl6-slang-roman lets you write your Perl 6 code using Roman numerals: