0

I have been experimenting with JSoup recently and I'm not so sure on how to extract a table from a site. For example, the table that I'm trying to get is the historical data table from https://coinmarketcap.com/currencies/bitcoin/historical-data/.

This is the code that I wrote

public static void checkChange(Document d){
    Elements table = d.select("div.b4d71h-2.hgYnhQ > table.h7vnx2-2.hLKazY.cmc-table > tbody > tr:eq(1)");
    for(Element ele : table){
        System.out.println(ele.text());
    }
}

Document d is the Jsoup.connect(URL).get(); passed from another function.

I'm trying to retrieve the specific row[6] and row[29] only but at the moment I am unable to even retrieve the table hence the for loop function doesn't even run as it does not print anything.

I would appreciate any help and preferably explanations regarding how to get the table from the webpage. I would add the HTML code however, there are a lot of entries in the table and I didn't add it as it would clutter this entire post with data.

  • If you disable JavaScript in your browser and you reload this page you will see that this table will not be shown. It means that it is generated dynamically by JavaScript. Problem is that `jsoup` is not browser *emulator* but simple parser, so it doesn't include JavaScript support. It only parses HTML data it received. You need other tool/library, like Selenium web-driver. – Pshemo Dec 27 '21 at 12:13

0 Answers0