0

I am working on a web scraper to gather stats from https://www.nba.com for a project, but my scraper is somehow not gathering data from the table, as the table says it has size 0 (makes it seem like its not getting the table at all).

Could someone let me know if I am doing something wrong and how to fix it?

My NBA scraper code

The inspect code from NBA.com

I tried to gather from table tbody.Crom_body__UYOcU and to make sure it worked, I checked the size. Should've been much more than 0 (50 or 100 I do not remember) but returned just 0 from size().

Janez Kuhar
  • 3,705
  • 4
  • 22
  • 45
mjbux
  • 1
  • 1
  • Please provide enough code so others can better understand or reproduce the problem. – Community Dec 20 '22 at 20:22
  • 2
    The inspect tools are not very useful for this use-case as they show the generated HTML after all scripts were run. Jsoup instead just fetches the initial HTML without running any scripts. If you take a look at the context menu > View Source you'll see that the HTML of this page does not contain the statistics eventually shown – Roland Kreuzer Dec 20 '22 at 22:34
  • 1
    In other words: In a world of JS frameworks and XHR requests good old HTML scraping as JSOUP provides it might simply not provide you with any useful information – Roland Kreuzer Dec 20 '22 at 22:37
  • However, if you check the inspect tool's network tab you'll see the content data loaded as JSON from https://stats.nba.com/stats/leagueLeaders?LeagueID=00&PerMode=PerGame&Scope=S&Season=2022-23&SeasonType=Regular%20Season&StatCategory=PTS For a hobby project you could as well fetch it from there – Roland Kreuzer Dec 20 '22 at 22:42
  • Hello, welcome to StackOverflow! I see you haven't yet taken the [tour]. Also, take a look at [ask]. Do not post images of your code but rather [edit] your question and paste it as a formatted code block. – Janez Kuhar Dec 21 '22 at 18:16

0 Answers0