添加依赖:
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.9.1</version>
</dependency>
一、类型选择器 .类型
二、层级选择器
获取行级元素 ul
获取块级元素 li #在括号里
#语法:当类型中使用空格分割时,需要使用多个select选择器
1.String url=“http://www.baidu.com/“
2.Document document
3.Elements elements
4.String imageUrl/imageName //图片地址或名字
5.String imageDir
6.String num
7.String strNum
8.Book book. //set入图片url,图片名字,价格,类型,人数
9.BookMapper bookMapper
10.Response response
11.byte[] bytes
12.String filePath
13.File file
14.OutputStream outputStream
15.Connection connection
16.String json
2=Jsoup.connect(1).ignoreContenType(true).get();
3=2.select(“.xx”).select(“.xx”);
3.size(); //得到数据个数
4=3.select(“.xx”).attr(“xx”); //获得图片地址 //.text()
5=findImage(4);
6=3.select(“xx”).get(1个).text();
7=6.substringh(0个,1.indexOf(“人“));
7=7.replace(“,”,””);
//7和5都set入8
9.insert(8);
10=Jsoup.connect(1).ignoreContentType(true).execute();
11=10.bodyAsBytes();
12=磁盘路径”+1.substring(1.lastIndexOf(“/“)+1个);
13=12 //新建对象参数传入
14=13 //新建对象参数传入
14.write(11);
15=Jsoup.connect(1);
15.data(“pageSize”,”页数”);
15.data(“pages”,”第一页”);
16=15.ignoreContentType(true).execute().body();
Jsoup网页解析实践
1194

被折叠的 条评论
为什么被折叠?



