Jsoup 如何从 html table 的特定列中获取文本

Jsoup how to get text from a specific column of an html table

我试图打印出此维基百科页面 table 中的所有位置:https://en.wikipedia.org/wiki/COVID-19_pandemic,但它始终显示为空白。这是我的代码有问题还是我在搜索错误的 html 类?

            try {
                Document doc = Jsoup.connect("https://en.wikipedia.org/wiki/COVID-19_pandemic").get();
                for (Element row : doc.select("table.wikitable.plainrowheaders.sortable.jquery-tablesorter tr")){
                    if (row.select("th:nth-of-type(2)").text().equals("")){
                        continue;
                    }else {
                        final String location = row.select("th:nth-of-type(2)").text();
                        System.out.println(location);
                    }
                }
            } catch (IOException e) {
                e.printStackTrace();
            }

当我变了

doc.select("table.wikitable.plainrowheaders.sortable.jquery-tablesorter tr")

doc.select("table.wikitable tr")

我能够得到国家名称。

请尝试。