1.引入Maven
org.jsoup jsoup1.8.3
2. 用法
public void test() {
//地址:
String url ="https://www.*******.cn/";
Connection tempConn = Jsoup.connect(url);
//模拟浏览器的请求头
tempConn.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0");
//开始连接HTTP请求。
Connection.Response response;
try {
response = tempConn.ignoreContentType(true).method(Connection.Method.GET)
.execute();
document documentDemo = response.parse();
//获取该页面的HTML元素。
String str = documentDemo.toString();
System.out.println(str);
//正则匹配
Pattern pattern = Pattern.compile("https:/[0-9]{4}/[0-9]{2}/[0-9]{2}/[A-Za-z]+[0-9]+.shtml");
Matcher matcher = pattern.matcher(str);
while(matcher.find()) {
System.out.println(matcher.group());
}
} catch (IOException e) {
e.printStackTrace();
}
}



