从网站获取实时数据... Jsoup? OCR?

时间:2015-05-25 19:15:01

标签: java web-scraping jsoup screen-scraping ocr

我需要从投注网站获得一些现场足球统计数据 - 使用java。我的第一个想法是使用Jsoup,但似乎没有给我任何输出。

我做错了吗?这是我试图抓的网页类型吗?如果是这样,我可以使用OCR来获取我所需的统计数据吗?

Document doc = Jsoup.connect("https://www.betfair.com/sport/football/event?eventId=27446056").get();

String shots = doc.select("#in-game-stats > div:nth-child(1) > div.si-home-value").text();
System.out.println(shots);

1 个答案:

答案 0 :(得分:-1)

这是您想要的教学视频:

https://www.youtube.com/watch?v=tI1qGwhn_bs&ab_channel=ShaneLee

public class Stock {

public Stock() {
    final String url =
            "https://sharestobeclosed.telegraph.co.uk/indices/financials/index/MCX";

    try {
        final Document document = Jsoup.connect(url).get();

        for (Element row : document.select(
                "table.tablesorter.full tr")) {
            if (row.select("td:nth-of-type(1)").text().equals("")) {
                continue;
            } else {
                final String ticker =
                        row.select("td:nth-of-type(1)").text();
                final String name =
                        row.select("td:nth-of-type(2)").text();
                final String tempPrice =
                        row.select("td.right:nth-of-type(3)").text();
                final String tempPrice1 =
                        tempPrice.replace(",", "");
//                    final double price = Double.parseDouble(tempPrice1);

                System.out.println(ticker + " " + name + " " + tempPrice1);
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

}