Jsoup webscraping to find game odds data

54 Views Asked by At

I've been trying to create a program in Java that can catch the odds of a game from a sportsbook like FanDuel but I've been running into a lot of problems. When I print the html for the site I dont get the entire html for the site so Im unable to go into the divs and retrieve the actual data I want. I used the Url https://sportsbook.fanduel.com/ . If I try and run a method like Elements element = doc.getElementByID("root"); to get the data inside that div the rest of the data in that div will not appear. enter image description here. I specifically would just like to get the moneyline data for each game if anyone can help that would be great

public class ExtractSportsBookData {
    public static void extractData(String url){
        try{
            Document doc = Jsoup.connect(url).get();
            String html = doc.html();
            System.out.println(html);
            
        } catch (IOException e){
            e.printStackTrace();
        }

    }

}

enter image description here If you look at the image inside the li tags is where the data is stored for the moneylines for each game but I cannot seem to find a way to extract that data using Jsoup

public class Main {
    public static void main(String[] args) {
        ExtractSportsBookData.extractData("https://sportsbook.fanduel.com/");

    }
}


import java.io.IOException;
import java.io.SyncFailedException;

public class ExtractSportsBookData {
    public static void extractData(String url){
        try{
            Document doc = Jsoup.connect(url).get();
            String html = doc.html();
            //System.out.println(html);
            Elements element = doc.getElementsByClass("jo jp fk fe jy jz bs");
            System.out.println(element.isEmpty());

        } catch (IOException e){
            e.printStackTrace();
        }

    }

}

enter image description here The result I receive from this is true meaning that the element is empty which is not what I want. Any help on this would be appreciated

0

There are 0 best solutions below