[英]How to extract text ONLY from html file using jsoup
I have used this code : 我用过这段代码:
String innerHtml = Jsoup.parse(htmlCode,"ISO-8859-1").select("body").html();
But it only removes <html>
tags 但它只删除
<html>
标签
Any HTML
tags inside the body
will still appear 仍然会出现
body
任何HTML
标记
使用.text()
而不是.html()
来获取元素及其所有子元素的组合文本。
Try using .text()
: 尝试使用
.text()
:
Jsoup.parse(htmlCode,"ISO-8859-1").select("body").text();
Instead of .html()
. 而不是
.html()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.