Answer the question
In order to leave comments, you need to log in
How to parse a web page using Jsoup?
public void methodAddDataTop3(TableView table) throws IOException {
TableViewController tvController = new TableViewController();
tvController.methodTableItemsClear(table);
Document doc = Jsoup.connect("http://www.stoloto.ru/keno2/archive/").get();
Elements newsHeadlines = doc.select("div.ashjf-0.dkbhVc");
System.out.println(newsHeadlines.get(1).text());
}
Caused by: java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
Answer the question
In order to leave comments, you need to log in
Good afternoon.
As noted by colleague Sergey Gornostaev , the content of this page is formed dynamically. Accordingly, jsoup will not work.
You need to make a GET request to the REST service URL and get json, which will then need to be parsed.
Open your browser console and go to the "Network" tab. Select XHR in the filters and examine the requests.
You will see this url:
https://www.stoloto.ru/p/api/mobile/api/v34/service/draws/archive?count=10&game=keno2
Start the debugger and see what data is being processed when the error occurs. Probably, the numbers you are interested in are formed by javascript, and therefore they are not on the page for JSoup.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question