probberechts / soccerdata

⛏⚽ Scrape soccer data from Club Elo, ESPN, FBref, FiveThirtyEight, Football-Data.co.uk, FotMob, Sofascore, SoFIFA, Understat and WhoScored.
https://soccerdata.readthedocs.io/en/latest/
Other
580 stars 101 forks source link

[FBRef] ValueError: not enough values to unpack (expected 1, got 0) #665

Open llowe10 opened 1 month ago

llowe10 commented 1 month ago

Running into the following error when reading team season stats with latest version of soccerdata package 1.8.1 running on python3.12 in anaconda environment.

ValueError                                Traceback (most recent call last)
Cell In[2], line 1
----> 1 fbref.read_team_season_stats(stat_type="standard")

File ~\anaconda3\envs\python312\Lib\site-packages\soccerdata\fbref.py:319, in FBref.read_team_season_stats(self, stat_type, opponent_stats)
    317 # parse HTML and select table
    318 tree = html.parse(reader)
--> 319 (html_table,) = tree.xpath(
    320     f"//table[@id='stats_teams_{stat_type}' or @id='stats_squads_{stat_type}']"
    321 )
    322 df_table = _parse_table(html_table)
    323 df_table["league"] = lkey

ValueError: not enough values to unpack (expected 1, got 0)
Klausul commented 1 month ago

I'm having the same issue, how did you solve it?

llowe10 commented 1 month ago

I'm having the same issue, how did you solve it?

@Klausul - I actually haven't solved it, so I reopened the issue. For some reason I'm running into the issue on one of my devices, but it works fine on my other device.

probberechts commented 1 month ago

The following works fine for me:

fbref = sd.FBref("ESP-La Liga", "23-24", no_cache=True)
fbref.read_team_season_stats(stat_type="standard")

For which league / season are you experiencing problems?