1.依赖
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.10.2</version>
</dependency>
2.解析
public static void main(String[] args) {
String htmlStr="<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/><title>错误页面</title>"
+ "</head><body><h1>500:请求失败,请查看日志!</h1></body></html>";
Document document = Jsoup.parse(htmlStr);
Elements h1 = document.getElementsByTag("h1");
String text = h1.text();
Elements meta = document.getElementsByAttribute("content");
String content = meta.attr("content");
}