【发布时间】:2019-08-07 20:39:59
【问题描述】:
我正在尝试使用 Mojo::DOM 从 HTML 文件中提取一些没有标签的文本(我是新手)。特别是H2标题后的描述文字(文件中还有其他标题)。
<h2>Description</h2>This text is the description<div class="footer">[<a href="/contrib/rev/1597/2795/">Edit description</a>
我已经能够找到标题,但不知道如何访问后面的文本,因为我没有标签可以跳转到...
my $dom = Mojo::DOM->new( $htmlfile );
my $desc = $dom
->find('h2')
->grep(sub { $_->all_text =~ /Description/ })
->first;
谁能向我推荐一种获取“This text is the description”字符串的方法?
【问题讨论】:
-
您能否发布更多 HTML,例如父元素。