[GH-ISSUE #370] [FBref] match-level opponent data not available for read_team_match_stats #70

Closed
opened 2026-03-02 15:55:31 +03:00 by kerem · 4 comments
Owner

Originally created by @mhd0528 on GitHub (Sep 15, 2023).
Original GitHub issue: https://github.com/probberechts/soccerdata/issues/370

Hi, is getting opponent team info from read_team_match_stats still supported? I got the following error. Any suggestions how to fix this? Thanks in advance!

File "/home/anaconda3/envs/soccerdata/lib/python3.10/site-packages/soccerdata/fbref.py", line 432, in read_team_match_stats
    (html_table,) = tree.xpath(f"//table[@id='matchlogs_{opp_type}']")
ValueError: not enough values to unpack (expected 1, got 0)
Originally created by @mhd0528 on GitHub (Sep 15, 2023). Original GitHub issue: https://github.com/probberechts/soccerdata/issues/370 Hi, is getting opponent team info from `read_team_match_stats `still supported? I got the following error. Any suggestions how to fix this? Thanks in advance! ``` File "/home/anaconda3/envs/soccerdata/lib/python3.10/site-packages/soccerdata/fbref.py", line 432, in read_team_match_stats (html_table,) = tree.xpath(f"//table[@id='matchlogs_{opp_type}']") ValueError: not enough values to unpack (expected 1, got 0) ```
kerem 2026-03-02 15:55:31 +03:00
  • closed this issue
  • added the
    FBref
    label
Author
Owner

@probberechts commented on GitHub (Sep 24, 2023):

They are simply not available for the "schedule" stat type

<!-- gh-comment-id:1732512683 --> @probberechts commented on GitHub (Sep 24, 2023): They are simply not available for the "schedule" stat type
Author
Owner

@mhd0528 commented on GitHub (Sep 25, 2023):

Ok thanks! I'll look into other types of stats first then.

<!-- gh-comment-id:1733737994 --> @mhd0528 commented on GitHub (Sep 25, 2023): Ok thanks! I'll look into other types of stats first then.
Author
Owner

@mhd0528 commented on GitHub (Sep 25, 2023):

Okay so I tried to disable the local cache and with other stat types other than schedule, but it still gives me a scraping error like below:

Error while scraping                                                         _common.py:351
                             [](https://fbref.com/en/squads/18bb7c10/matchlogs/all_comps/shooting.)

And I checked this url, it is not valid in FBref. The closest valid link I can find is: https://fbref.com/en/squads/18bb7c10/2023-2024/matchlogs/all_comps/shooting/Arsenal-Match-Logs-All-Competitions. Is it possible that there is some error in the url generation? Sorry for bothering you recently, I'm trying to figure out what's the error on my end, but can't solve it...

<!-- gh-comment-id:1733908091 --> @mhd0528 commented on GitHub (Sep 25, 2023): Okay so I tried to disable the local cache and with other stat types other than schedule, but it still gives me a scraping error like below: ``` Error while scraping _common.py:351 [](https://fbref.com/en/squads/18bb7c10/matchlogs/all_comps/shooting.) ``` And I checked this url, it is not valid in FBref. The closest valid link I can find is: https://fbref.com/en/squads/18bb7c10/2023-2024/matchlogs/all_comps/shooting/Arsenal-Match-Logs-All-Competitions. Is it possible that there is some error in the url generation? Sorry for bothering you recently, I'm trying to figure out what's the error on my end, but can't solve it...
Author
Owner

@mhd0528 commented on GitHub (Sep 25, 2023):

I think I might find out what's the problem.
When I scrape data before the current season, e.g. fbref = sd.FBref(leagues='ENG-Premier League', seasons='2022-23'), I'm able to get team_match data with those stat_types.
But if I use fbref = sd.FBref(leagues='ENG-Premier League', seasons='2023-24'), it will give me the error above.

---update---
I checked the team URLs of the current season and previous seasons. The URL for the current season doesn't have season in it. See the example below:
2022-23: Arsenal /en/squads/18bb7c10/2022-2023/Arsenal-Stats
2023-24: Arsenal /en/squads/18bb7c10/Arsenal-Stats
This will lead to an invalid URL for the team match log. I'll try to add a condition to deal with it.

---update---
I have updated the code in my fork and I'm testing it with more history seasons + leagues. I'll pull a merge request once it's verified.

---update---
I have tested the code and it should be good now. Create a PR for it. Hope it help.
https://github.com/probberechts/soccerdata/pull/384

<!-- gh-comment-id:1734425686 --> @mhd0528 commented on GitHub (Sep 25, 2023): I think I might find out what's the problem. When I scrape data before the current season, e.g. `fbref = sd.FBref(leagues='ENG-Premier League', seasons='2022-23')`, I'm able to get team_match data with those stat_types. But if I use `fbref = sd.FBref(leagues='ENG-Premier League', seasons='2023-24')`, it will give me the error above. ---update--- I checked the team URLs of the current season and previous seasons. The URL for the current season doesn't have `season` in it. See the example below: 2022-23: `Arsenal /en/squads/18bb7c10/2022-2023/Arsenal-Stats` 2023-24: `Arsenal /en/squads/18bb7c10/Arsenal-Stats` This will lead to an invalid URL for the team match log. I'll try to add a condition to deal with it. ---update--- I have updated the code in my fork and I'm testing it with more history seasons + leagues. I'll pull a merge request once it's verified. ---update--- I have tested the code and it should be good now. Create a PR for it. Hope it help. https://github.com/probberechts/soccerdata/pull/384
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/soccerdata#70
No description provided.