Jsoup 提取 child 个 div
Jsoup extracting child of a div
我正在尝试为网站上的某些广告提取 link,但我无法使其正常工作:( div 如下所示:
我无法使用 href class id 提取它,因为其他 links 有不同的 classes 这让我尝试使用 h3 class id 每次添加都是一样的,但我无法让它工作,或者我肯定做错了什么。
Elements pageSearch3 = page2.select(".lheight22.margintop5");
for(int l = 0; l < pageSearch3.size(); l++) {
String url = pageSearch3.get(l).attr("href");
System.out.println(url);
}
查看选择器文档https://jsoup.org/cookbook/extracting-data/selector-syntax。
parent > child: child elements that descend directly from parent, e.g.
div.content > p finds p elements; and body > * finds the direct
children of the body tag
我正在尝试为网站上的某些广告提取 link,但我无法使其正常工作:( div 如下所示:
我无法使用 href class id 提取它,因为其他 links 有不同的 classes 这让我尝试使用 h3 class id 每次添加都是一样的,但我无法让它工作,或者我肯定做错了什么。
Elements pageSearch3 = page2.select(".lheight22.margintop5");
for(int l = 0; l < pageSearch3.size(); l++) {
String url = pageSearch3.get(l).attr("href");
System.out.println(url);
}
查看选择器文档https://jsoup.org/cookbook/extracting-data/selector-syntax。
parent > child: child elements that descend directly from parent, e.g. div.content > p finds p elements; and body > * finds the direct children of the body tag