gpt4 book ai didi

java - 如何提取在网页 JSoup 中找到的所有文本

转载 作者:行者123 更新时间:2023-11-29 05:20:27 25 4
gpt4 key购买 nike

<分区>

有谁知道我如何提取<p> blah blah blah </p>
以外的文本(基本上在其他元素中也能找到文本)`
在网页中。它必须是一个完整的时间顺序,因为它是如何在原始 webapge 中显示的。

我的意思是超越<p> tags也可以从 <h1>, <h2>,<h3> and <h4> 中提取标题中的单词也!所以例如给定一个 html 网页

<html> 
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<p>This is a random paragraph</p>
<h1>Heading3</h1>
<p>This is another random paragraph</p>
</html>

*如果网页在主体中也有 p 标签之后的标签,这会变得有点复杂。

因此,所需的(按时间顺序排列的)输出将如上所示!

*使用 JSoup! :)

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com