From 612966a15725d949ebb2a248ebba6d40a9fe3d41 Mon Sep 17 00:00:00 2001 From: JaseZiv Date: Wed, 17 Jan 2024 21:06:41 +1100 Subject: [PATCH] fix missing player valuations in bios --- DESCRIPTION | 2 +- NEWS.md | 1 + R/tm_player_bio.R | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 73a3fafd..8c149cfd 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: worldfootballR Title: Extract and Clean World Football (Soccer) Data -Version: 0.6.5.0001 +Version: 0.6.5.0002 Authors@R: c( person("Jason", "Zivkovic", , "jaseziv83@gmail.com", role = c("aut", "cre", "cph")), person("Tony", "ElHabr", , "anthonyelhabr@gmail.com", role = "ctb"), diff --git a/NEWS.md b/NEWS.md index 9060421c..30d3afa3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +3,7 @@ ### Bugs * `fb_league_stats()` not returning `opponent` table. (0.6.5.0001) [#355](https://github.com/JaseZiv/worldfootballR/issues/355) +* `tm_player_bio()` not returning values in the `player_valuation`, `max_player_valuation` and `max_player_valuation_date` fields. Unfortunately, `max_player_valuation` and `max_player_valuation_date` fields are no able to be scraped at this release (0.6.5.0002) [#357](https://github.com/JaseZiv/worldfootballR/issues/357) *** diff --git a/R/tm_player_bio.R b/R/tm_player_bio.R index f9af72f6..70d74e20 100644 --- a/R/tm_player_bio.R +++ b/R/tm_player_bio.R @@ -52,9 +52,9 @@ tm_player_bio <- function(player_urls) { # handle for duplicate socials a <- a %>% dplyr::distinct(X1, .keep_all = TRUE) - player_val <- tryCatch(player_page %>% rvest::html_nodes(".tm-player-market-value-development__current-value") %>% rvest::html_text() %>% - stringr::str_squish(), error = function(e) NA_character_) %>% .replace_empty_na() - player_val_max <- tryCatch(player_page %>% rvest::html_nodes(".tm-player-market-value-development__max-value") %>% rvest::html_text() %>% + player_val <- tryCatch(player_page %>% rvest::html_nodes(".data-header__market-value-wrapper") %>% rvest::html_text() %>% + stringr::str_squish() %>% gsub(" Last.*", "", .), error = function(e) NA_character_) %>% .replace_empty_na() + player_val_max <- tryCatch(player_page %>% rvest::html_nodes(".max") %>% rvest::html_text() %>% stringr::str_squish(), error = function(e) NA_character_) %>% .replace_empty_na() player_val_max_date <- tryCatch(player_page %>% rvest::html_nodes(".tm-player-market-value-development__max div") %>% .[3] %>% rvest::html_text() %>% stringr::str_squish(), error = function(e) NA_character_) %>% .replace_empty_na()