Hi people.

The essence of the issue: parse the site using Jsoup. Jsoup stubbornly refuses to see the id of the table, moreover, it is all hidden (in the browser, the entire structure of the document is visible).

The data in the table is updated once a minute. I am following the second scenario: I save the page locally on my computer and everything is normal, it works. What is it and how can you get around the problem?

Thank you for your attention to the question.

  • one
    "What is it?" Is possible (a reproduced example of the problem, because you did not bring it), the table is built using JS after the page loads. In this case, you need to save a fully-formed page using a browser (manually or automatically. I don’t know how to do it automatically), after which parse the saved version. - Regent
  • Give a link to the site that parse. just correct the tags, javascript and java are not the same thing. - webDev_

1 answer 1

Using Jsoup directly will not be able to parse the required information from this page, because it is generated dynamically, as far as I understand, using PHP.

However, there is a solution:

We take any sniffer and see what happens during the page loading process. For simplicity, you can use the tool built into Google Chrome: press Ctrl + Shift + I , go to the Network tab, reload the page and catch the moment at which the table is loaded. While loading the table in the Network tab Network we see the following:

enter image description here

As you can see from the screenshot, the table is generated using PHP. Next, take the URL and go through it in the browser:

 http://hrk.aero/table/ajax_tablo_new.php?lang=ru&full=1&first=1 

And, about a miracle, the required table is displayed.

Next, use the resulting URL in Jsoup:

 public class Main { public static void main(String[] args) throws IOException { Document page = Jsoup.connect("http://hrk.aero/table/ajax_tablo_new.php?lang=ru&full=1&first=1").get(); System.out.println(page); } } 

And in the console we see the HTML code of the required table:

enter image description here

It remains only to parse this table. This, as I understand it, you know how.

  • thank. I do not know php I will learn. You chewed it all up, which is a shame for you. - Alex Lexis
  • @Lexis, I also do not know PHP, but here it is not necessary to know it. We just need general knowledge of web. It's okay, everyone always learns something new :) - post_zeew