我是 JSoup 新手,我想要获取此特定 HTML 标记中写入的文本:
<pre class="cg-msgbody cg-view-msgbody"><span class="cg-msgspan"><span>**the text I want to get is present here, how can I get it using JSoup?**</span></span></pre>
如有任何帮助,我们将不胜感激。
谢谢!
最佳答案
String html = "<pre class=\"cg-msgbody cg-view-msgbody\">"
+ "<span class=\"cg-msgspan\">"
+ "<span>**the text I want to get is present here, "
+ "how can I get it using JSoup?**</span>"
+ "</span>"
+ "</pre>";
org.jsoup.nodes.Document document = Jsoup.parse(html);
//a with href
Element link = document.select("span").last();
System.out.println("Text: " + link.text());
关于java - 使用 JSoup 获取特定的(预先格式化的)文本(从网站),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54861688/