Reputation: 125
I'm trying to extract the link for some ads on an website but i can't manage to make it work:( The div looks like this:
I can't extract it by using the a href class id because other links have different classes which made me try to extract it by using the h3 class id which is the same for every add but i can't get it to work or i'm surely doing something wrong.
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);
}
Upvotes: 1
Views: 36
Reputation: 759
Take a look of the selector documentation 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
Upvotes: 2