0

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

gBarry
  • 1
  • It’s unlikely to be a static site. – Dave Newton Feb 02 '23 at 02:03
  • @DaveNewton shouldn't I still be able to extract the html data in the moment? – gBarry Feb 02 '23 at 02:10
  • 2
    Not if it’s generated dynamically, no; IIRC JSoup doesn’t do JS. For that you need to drive a full, headless or not, or reverse engineer their back end requests. *Noting that either are almost certainly against their TOS (but I’m guessing).* – Dave Newton Feb 02 '23 at 02:50
  • Does this answer your question? [Page content is loaded with JavaScript and Jsoup doesn't see it](https://stackoverflow.com/questions/7488872/page-content-is-loaded-with-javascript-and-jsoup-doesnt-see-it) – Janez Kuhar Feb 05 '23 at 14:46

0 Answers0