网页抓取Java

时间:2018-08-19 08:12:26

标签: java jsoup

我正在尝试抓取网页以提取银行汇率,但面临一些问题。代码是:

public class Main {

    public static void main(String[] args) throws IOException {
        Document doc = Jsoup.connect("http://www.banki.ru/products/currency/cash/usd/tyumen~/#bank-rates").get();

        //this is what I'm trying to extract, but the block below "tr[]data-currencies-row" is generated by JavaScript
        Elements elements1 = doc.select("tr[data-currencies-row]");
        System.out.println(elements1.size());   //prints 0

        //this block below works fine
        Elements elements2 = doc.select("a[class^=font-bold]");
        System.out.println(elements2.size());   //prints 3
    }
}

如何导航到“ tr [data-currencies-row]”标签?

0 个答案:

没有答案
相关问题