我正在尝试使用Mojo :: DOM从HTML文件中提取一些没有标签的文本(这是我的新手)。特别是,H2标题(文件中还有其他标题)之后的描述文本。
<h2>Description</h2>This text is the description<div class="footer">[<a href="/contrib/rev/1597/2795/">Edit description</a>
Run Code Online (Sandbox Code Playgroud)
我已经能够找到标题,但是之后不知道如何访问文本,因为我没有标签来跳转到...
my $dom = Mojo::DOM->new( $htmlfile );
my $desc = $dom
->find('h2')
->grep(sub { $_->all_text =~ /Description/ })
->first;
Run Code Online (Sandbox Code Playgroud)
谁能向我推荐一种方法来获取“此文字为描述”字符串?