0

我有一个这样的节点

<div>&gt; something &lt;</div>

我需要像这样获取 div 元素的文本

&gt; something &lt;

我从 .text() 方法得到的,输出是

> something <

在 BeautifulSoup 中,它将返回&gt; something &lt;未编码的输出。

如何从 JSoup 获取未转换的文本?

4

1 回答 1

0
doc = Jsoup.connect(url).get();
doc.outputSettings().escapeMode(Entities.EscapeMode.extended);

或者

为此使用 Apache Commons StringEscapeUtils.unescapeHtml4()

Unescapes a string containing entity escapes to a string containing the actual Unicode characters corresponding to the escapes. Supports HTML 4.0 entities.
于 2013-07-03T12:20:25.757 回答