开发者

Handling special entities like & nbsp; , & pound; in 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 &pound or quotes etc. For e.x. for url : http://www.basiceleganc开发者_StackOverflow社区efurnishings.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


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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜