JaseZiv / worldfootballR

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

Can't scrap Champions League matches from Fotmob #111

Closed QuantQB8 closed 2 years ago

QuantQB8 commented 2 years ago

Hi again!

I'm trying to webscrap data from distinct leagues and all is ok until i try to scrap data for champions league matches. For example, I can see the match for Liverpool-Benfica with fotmob_get_matches_by_date("20220405"), but when fetching data from its match_id = 3846347 in fotmob_get_match_players(3846347) it returns an empty dataframe (it happens for all champions league matches, but for the other leagues is ok!).

I downloaded the last dev package of worldfootballR. My R session is:

R version 4.1.3 (2022-03-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.3.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods  
[7] base     

other attached packages:
 [1] lubridate_1.8.0           worldfootballR_0.5.1.3000
 [3] forcats_0.5.1             stringr_1.4.0            
 [5] dplyr_1.0.8               purrr_0.3.4              
 [7] readr_2.1.2               tidyr_1.2.0              
 [9] tibble_3.1.6              ggplot2_3.3.5            
[11] tidyverse_1.3.1          

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.8.3      prettyunits_1.1.1 ps_1.6.0         
 [4] assertthat_0.2.1  rprojroot_2.0.3   utf8_1.2.2       
 [7] R6_2.5.1          cellranger_1.1.0  backports_1.4.1  
[10] reprex_2.0.1      httr_1.4.2        pillar_1.7.0     
[13] rlang_1.0.2       curl_4.3.2        readxl_1.3.1     
[16] rstudioapi_0.13   callr_3.7.0       desc_1.4.1       
[19] devtools_2.4.3    selectr_0.4-2     munsell_0.5.0    
[22] broom_0.7.12      janitor_2.1.0     compiler_4.1.3   
[25] modelr_0.1.8      pkgconfig_2.0.3   pkgbuild_1.3.1   
[28] tidyselect_1.1.2  fansi_1.0.3       crayon_1.5.1     
[31] tzdb_0.3.0        dbplyr_2.1.1      withr_2.5.0      
[34] brio_1.1.3        grid_4.1.3        jsonlite_1.8.0   
[37] gtable_0.3.0      lifecycle_1.0.1   DBI_1.1.2        
[40] magrittr_2.0.3    scales_1.1.1      stringi_1.7.6    
[43] cli_3.2.0         cachem_1.0.6      fs_1.5.2         
[46] remotes_2.4.2     testthat_3.1.3    snakecase_0.11.0 
[49] xml2_1.3.3        ellipsis_0.3.2    generics_0.1.2   
[52] vctrs_0.4.0       tools_4.1.3       glue_1.6.2       
[55] hms_1.1.1         processx_3.5.2    pkgload_1.2.4    
[58] fastmap_1.1.0     colorspace_2.0-3  sessioninfo_1.2.2
[61] rvest_1.0.2       memoise_2.0.1     haven_2.4.3      
[64] usethis_2.1.5    

Thanks a lot again! Regards

JaseZiv commented 2 years ago

I might be wrong, but non-domestic leagues might not be supported.

Is that correct @tonyelhabr?

tonyelhabr commented 2 years ago

See #112. This is a bug. I added a test for a non-domestic match so hopefully we will be alarmed to things like this in the future.

fotmob_get_match_players(3846347)
# A tibble: 46 x 32
   match_id team_id team_name id     using_opta_id first_name last_name image_url page_url shirt is_home_team time_subbed_on
      <int>   <int> <chr>     <chr>  <lgl>         <chr>      <chr>     <chr>     <chr>    <chr> <lgl>                 <int>
 1  3846347    9772 Benfica   304355 FALSE         "Odisseas" Vlachodi~ https://~ /player~ 99    TRUE                     NA
 2  3846347    9772 Benfica   387499 FALSE         "Gilberto" Junior    https://~ /player~ 2     TRUE                     NA
 3  3846347    9772 Benfica   174321 FALSE         "Nicolas"  Otamendi  https://~ /player~ 30    TRUE                     NA
 4  3846347    9772 Benfica   37762  FALSE         "Jan"      Vertongh~ https://~ /player~ 5     TRUE                     NA
 5  3846347    9772 Benfica   288406 FALSE         "Alex"     Grimaldo  https://~ /player~ 3     TRUE                     NA
 6  3846347    9772 Benfica   477023 FALSE         "Rafa"     Silva     https://~ /player~ 27    TRUE                     NA
 7  3846347    9772 Benfica   47394  FALSE         "Adel"     Taarabt   https://~ /player~ 49    TRUE                     NA
 8  3846347    9772 Benfica   521421 FALSE         "Julian"   Weigl     https://~ /player~ 28    TRUE                     NA
 9  3846347    9772 Benfica   528348 FALSE         ""         Éverton   https://~ /player~ 7     TRUE                     NA
10  3846347    9772 Benfica   940087 FALSE         "Goncalo"  Ramos     https://~ /player~ 88    TRUE                     NA
# ... with 36 more rows, and 20 more variables: time_subbed_off <int>, usual_position <int>, position_row <int>,
#   role <chr>, is_captain <lgl>, subbed_out <int>, g <int>, rating_num <chr>, rating_bgcolor <chr>, is_top_rating <lgl>,
#   is_match_finished <lgl>, fantasy_score_num <chr>, fantasy_score_bgcolor <chr>, home_team_id <int>,
#   home_team_color <chr>, away_team_id <int>, away_team_color <chr>, stats <df[,38]>, shotmap <list>, is_starter <lgl>
QuantQB8 commented 2 years ago

Hi! If I understood, you said that this is a known bug but in the future maybe can be fixed? Or in this last version worldfootballR_0.5.1.4000 was fixed? If the last is correct, then I still can't scrap data from the example you said @tonyelhabr.

As always, thanks a lot!

tonyelhabr commented 2 years ago

Hi! If I understood, you said that this is a known bug but in the future maybe can be fixed? Or in this last version worldfootballR_0.5.1.4000 was fixed? If the last is correct, then I still can't scrap data from the example you said @tonyelhabr.

As always, thanks a lot!

Oh, it wasn't a known bug before, so thank you for pointing this out! It won't be fixed until the #112 PR is merged, which also bumps the package version to 0.5.1.5000.

If you're very anxious to try it out, I think you might be able to do it by installing the new version as follows.

remotes::install_github("JaseZiv/worldfootballR@f7f3ac99203b0503943164a2821845588595190c")

although I haven't tested it out

JaseZiv commented 2 years ago

This should now be resolved as Tony mentioned in version 0.5.1.5000.

Install it using devtools::install_github("JaseZiv/worldfootballR")

Feel free to open another issue if you're still finding problems.

Thanks