不知道是不是爬虫

<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.12.1</version>
</dependency>
      Document doc = null;
try {
doc = Jsoup.parse(new URL("http://music.taihe.com/top/dayhot"), 10000);
Elements select = doc.select("#songListWrapper ul li");
List<PaC> list = new ArrayList<>();
for (Element element:select){
Elements span = element.select("span");
PaC paC = new PaC();
for (int i = 0; i <span.size() ; i++) {
if (i==0){
System.out.println(span.get(i).text());
paC.setIndex(span.get(i).text());
}
if (i==2){
System.out.println(span.get(i).child(0).attr("title"));
paC.setName(span.get(i).child(0).attr("title"));
}
if (i==7){
//author
System.out.println(span.get(i).attr("title"));
paC.setAuthor(span.get(i).attr("title"));
}

}
list.add(paC);
}
posted @ 2019-09-23 16:51  ±小马哥  阅读(263)  评论(0编辑  收藏  举报