Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix missing player valuations in bios #358

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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", , "[email protected]", role = c("aut", "cre", "cph")),
person("Tony", "ElHabr", , "[email protected]", role = "ctb"),
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

***

Expand Down
6 changes: 3 additions & 3 deletions R/tm_player_bio.R
Original file line number Diff line number Diff line change
Expand Up @@ -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() %>%
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressing changes to html on transfermarkt

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() %>%
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately player_val_max and player_val_max_date are not accessible using html scraping and don;t really want to introduce the complications/flakiness of using promises for this fairly lightly used (I think) function

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()
Expand Down
Loading