【发布时间】:2016-03-02 01:15:57
【问题描述】:
我正在使用jsoup 清理一些 html。
我正在使用Whitelist.relaxed() 进行清洁。这在大多数情况下效果很好,我想继续使用它。
问题是我有一个占位符 href 值,清理正在删除。
例如,<a href="{placeholder}">text</a>。这将更改为<a>text</a>。有没有办法用我的place holder 值保留href attribute?
提前致谢
【问题讨论】:
-
你看过addAttributes白名单选项了吗?
-
我有。我创建了以下白名单: private static final Whitelist WHITELIST = Whitelist.relaxed().preserveRelativeLinks(true) .addTags("span") .addTags("hr") .addAttributes(":all", "style") 。 addAttributes(":all", "id") .addAttributes(":all", "target") .addProtocols("a", "href", "{");我已经玩了一点,但没有运气
标签: jsoup