如何使用jsoup解析html的dom标签

1、配置

<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.7.3</version>
</dependency>

2、代码
//网站源码
String html = getHtml("www.xxx.com");
System.out.println("官网html:"+html);
Document doc = Jsoup.parse(html);
Elements e_as = doc.getElementsByTag("a");//根据标签名找title元素
for(Element e_a : e_as){
System.out.println(e_a);
System.out.println(e_a.text());//获取标签的文字
}
原文地址:https://www.cnblogs.com/xing-nb/p/15226829.html