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
516 stars 88 forks source link

[FBref] Error getting player1 in some events #544

Closed nachouve closed 1 month ago

nachouve commented 2 months ago

Issue Summary:

I encountered an issue with soccerdata while parsing HTML for certain events in FBref.

Details: The error occurs in this line of the code where the player1 variable is set. Sometimes, there is no tag present here, but it has the name of person who was issued with a yellow card, for example.

Steps to Reproduce:

import soccerdata as sd
fbref = sd.FBref(seasons=['2324'], leagues=["ESP-La Liga"])
fbref.read_events(match_id="e8867e6b")

Expected Behavior: The read_events() function should handle cases where the tag is missing gracefully, rather than causing an error.

nachouve commented 2 months ago

Issue Update: It appears that the changes made in this commit address the reported problem.

Request for Review: As I'm not familiar with some of the technologies used in the project, @probberechts I would appreciate any guidance on potential improvements or corrections needed before merging the fix.

Thank you in advance for your assistance.

probberechts commented 2 months ago

I've added a suggestion on how to implement this a bit more cleaner. But functionally, your fix seems ok. Would you be able to create a pull request?

nachouve commented 2 months ago

I've added a suggestion on how to implement this a bit more cleaner. But functionally, your fix seems ok. Would you be able to create a pull request?

Perfect. I'll do it. Thank you!