JaseZiv / worldfootballR

A wrapper for extracting world football (soccer) data from FBref, Transfermark, Understat
https://jaseziv.github.io/worldfootballR/
433 stars 59 forks source link

FotMob Scraping Warning #297

Closed mcefis closed 12 months ago

mcefis commented 1 year ago

Good morning,

I had a problem with web scraping from FotMob; here below the warning:


**> Eredivisie_fotmob_rating <- fotmob_get_season_stats(

I have installed the last version of the library (worldfootballR_0.6.2). How can I fix this problem?

Let me know, many thanks.

Best regards, Mattia

tonyelhabr commented 1 year ago

Please install the latest version of worldfootballR (with remotes::install_github("JaseZiv/worldfootballR")) and let me know if you have the same issue.

I can't seem to replicate your issue with the latest version of the package.

library(worldfootballR)
packageVersion("worldfootballR")
#> [1] '0.6.3.8'
Eredivisie_fotmob_rating <- fotmob_get_season_stats(
  country = "NED",
  league_name = "Eredivisie",
  season_name = "2021/2022",
  stat_name = "Assists",
  team_or_player = "player"
)
dim(Eredivisie_fotmob_rating)
#> [1] 236  20
mcefis commented 1 year ago

I followed your instruction but I still have an error:

library(worldfootballR) packageVersion("worldfootballR") [1] ‘0.6.3.8’

1)Team stats

SerieA_team_stats_22_23 = fotmob_get_season_stats(

  • country = "ITA",
  • league_name = "Serie A",
  • season_name = "2022/2023",
  • stat_name = "xG conceded",
  • team_or_player = "team"
  • ) Error: no applicable method for 'distinct' applied to an object of class "list"

Let me know, many thanks

tonyelhabr commented 1 year ago

the message that you see is because .fotmob_get_stat_and_season_options() tries to scrape data for 2023/24 since the season option is shown in the menu, but there is no data yet for it (here). i can eliminate the message by setting quiet = TRUE here to prevent confusion.

in reality, you should still be getting a valid result from your function call despite the error message. observe that i get a 20-row dataframe back from the function call.

library(worldfootballR)
packageVersion("worldfootballR")
#> [1] '0.6.3.8'

res <- fotmob_get_season_stats(
  country = "ITA",
  league_name = "Serie A",
  season_name = "2022/2023",
  stat_name = "xG conceded",
  team_or_player = "team"
)
#> Error: no applicable method for 'distinct' applied to an object of class "list"
dim(res)
#> [1] 20 20

i may tackle this issue this weekend, but, as i've noted, you should still be getting valid data from the function call.

mcefis commented 1 year ago

You're right, it was a refuse: now it works! Many thanks