2016-12-13 116 views
0

的內容我有這樣的HTML源代碼,我想分析Jsoup脫逃的iframe

<div> 
<iframe><script>alert('hello')</script></iframe> 
</div> 

當我解析使用Jsoup和打印中的HTML我得到這個。

<div> 
<iframe>&lt;script&gt;alert('hello')&lt;/script&gt;</iframe> 
</div> 

我不想讓Jsoup轉換iframe中的內容。我怎樣才能做到這一點?。示例代碼

Document doc = Jsoup.parse(html); 
System.out.println(doc.body().html()); 

回答

2

可以使用jsoup解析器的unescapeEntities(字符串,boolean)方法:

Document doc = Jsoup.parse(html);    
System.out.println(org.jsoup.parser.Parser.unescapeEntities(doc.body().html(), true)); 
+0

嗯,這一切未逸出,不僅裏面有什麼