网站内容建设包括青岛seo
前言
jsoup解析页面默认是不包含换行符的,如果需要保留换行符,需要单独进行设置。
关键代码
String html = "</html>....</html>"
Document document = Jsoup.parse(html);
document.outputSettings(new Document.OutputSettings().prettyPrint(false));
document.select("br").append("\\n");
document.select("p").prepend("\\n");
String html1 = document.toString()
总结
上面只是简单的示例,大家可以自行尝试。