简体   繁体   中英

Java - Web Scraper Issue

I'm trying to scrape this page https://www.teamrankings.com/nba/team/cleveland-cavaliers but I need the grid that displays when you click 'Betting View'... I'm having some trouble. Is it even possible with the code I have? I'm getting null when I print div.

    String teamLink = "https://www.teamrankings.com/nba/team/cleveland-cavaliers/.betting"; // + Teams[i] + "/";

    Document doc = Jsoup.connect(teamLink).get();

    final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_45);
    HtmlPage page = webClient.getPage(teamLink);
    final HtmlDivision div = page.getFirstByXPath("div.btn-group");

    System.out.println(div);
    page = div.click();

There's no need to click the button. The data from both tabs seems to be in both tabs. The button appears to run a JavaScript function that shows and hides columns. Just fetch the whole table with ID DataTables_Table_0 and trash the columns you don't care about.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM