Closed endp01 closed 1 year ago
Reason So after some testing I found out why the error happens.
Example with uneven number of players (31): https://fbref.com/en/matches/e6066ef0/Sporting-CP-Manchester-City-February-15-2022-Champions-League This one will throw an error when trying fb_advanced_match_stats() on it.
match_page <- .load_page("https://fbref.com/en/matches/e6066ef0/Sporting-CP-Manchester-City-February-15-2022-Champions-League")
match_report <- .get_match_report_page(match_page = match_page)
Example with even number of players (28): https://fbref.com/en/matches/8a8090f1/Manchester-United-Roma-April-29-2021-Europa-League This one works with fb_advanced_match_stats() but will produce wrong entries in the league column.
match_page <- .load_page("https://fbref.com/en/matches/8a8090f1/Manchester-United-Roma-April-29-2021-Europa-League")
match_report <- .get_match_report_page(match_page = match_page)
Fix My suggestion to fix this would be to change the .get_match_report_page function in get_match_report.R (line 25) to just scrape the first occurence of the \<a> tag within the \<div>. Not sure if that's the cleanest way to go about it but it worked on my example above.
tryCatch( {League <- each_game_page %>% rvest::html_nodes("h1+ div a:nth-child(1)") %>% rvest::html_text()}, error = function(e) {League <- NA})
Hi @endp01, sorry for the late reply!
I will investigate this and look to have a fix in the next few days.
Thanks for raising and offering a possible solution.
When trying to scrape certain games I get this error message:
You can try to reproduce it with this function I used:
From what I can see, the table with the stats should be found by the regex "summary$". Not sure where the function fails. Interestingly fb_match_summary() works with the match URL above (https://fbref.com/en/matches/b5a4e26d/Tottenham-Hotspur-Sheffield-United-January-21-2015-League-Cup).
Anyways, thanks for your great work on the package!