处理特殊实体,如 & nbsp; , &磅;在 HtmlCleaner 中

发布于 2024-10-05 09:03:53 字数 453 浏览 0 评论 0原文

我正在使用 HtmlCleaner 库进行 html 内容提取。它工作得相当好,但有一些限制。

它无法处理特殊字符,例如 &pound 或引号等。例如 对于网址:http: //www.basicelegancefurnishings.co.uk/alaska-3-and-2-seater-sofa-setspan-classukmadespan-p-280.html,在给出价格的 xpath 时,它给了我“& pound;” ”代替 £

是否有我们可以在 htmlcleaner 中设置的任何属性来处理此或任何其他解决方案。

谢谢

吉腾德拉

I am using HtmlCleaner library for html content extraction. It works fairly but with few limitations.

It is not able to handle special characters like £ or quotes etc. For e.x.
for url : http://www.basicelegancefurnishings.co.uk/alaska-3-and-2-seater-sofa-setspan-classukmadespan-p-280.html, On giving xpath to price, It gives me "& pound;" inplace of £

Is there any property which we can set in htmlcleaner for handling this or any other solution.

Thanks

Jitendra

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

秋千易 2024-10-12 09:03:53

不,我不相信 HtmlCleaner 可以做到这一点。但是,您可以使用 Apache Commons StringEscapeUtils 对 html 进行“转义”,如下所示:

StringEscapeUtils.unescapeHtml("£679.00");

将产生 £679.00

我建议您尝试 JSoup,而不是 HtmlCleaner。

No, I don't believe HtmlCleaner can do this. However, you can use Apache Commons StringEscapeUtils to "unescape" the html, like this:

StringEscapeUtils.unescapeHtml("£679.00");

will produce £679.00.

Instead of HtmlCleaner, I would recommend you try JSoup.

维持三分热 2024-10-12 09:03:53

我使用的 htmlcleaner 版本是 2.2,org.htmlcleaner.CleanerProperties - setTransSpecialEntitiesToNCR(true) 对我很有用。虽然我必须使用 string.replace(" ", " ") 来使我得到的 html 内容完全正确。

The version of htmlcleaner I am using is 2.2, and org.htmlcleaner.CleanerProperties - setTransSpecialEntitiesToNCR(true) is useful to me. While I have to use the string.replace(" ", " ") to make the html content I got be right completely.

夜未央樱花落 2024-10-12 09:03:53

现在可以通过 org.htmlcleaner.CleanerProperties - setTransSpecialEntitiesToNCR(true) 来完成此操作。

This can now be done through org.htmlcleaner.CleanerProperties - setTransSpecialEntitiesToNCR(true).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文