Reputation: 31
Help solve the problem, it is necessary to pull some data from Wikipedia, I'll show them in the picture below:
In the page code, these data are here:
How to get this data? to do this is by using jsoup.
I tried to do it like this:
System.out.println(doc.select("div.mw-body-content > p ").first().text());
But the problem is that it so happens that this is not the first
in code, and the second is for something:
Upvotes: 0
Views: 84
Reputation: 31603
Get the parent div
by its ID (which should be unique):
Elements parent = doc.select("div#mw-body-content");
Get all p
tags in this element (including the second one you would like to have):
Elements paragraphs = parent.getElementsByTag("p");
Take the second of it:
String text = paragraphs.get(1).text();
Upvotes: 1