From 8bbb7b511c839248ca6e7c77ebedc97b939936b2 Mon Sep 17 00:00:00 2001 From: Anton <80207895+drasbaek@users.noreply.github.com> Date: Wed, 11 Sep 2024 15:13:03 +0100 Subject: [PATCH 1/3] enhancement: added date_of_birth to contract expiry The date of birth column is not scraped in the current/old version. This commit identifies the html code for the element and processes it by the same convention as the other variables --- R/tm_expiring_contracts.R | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/R/tm_expiring_contracts.R b/R/tm_expiring_contracts.R index f9d89b50..46d94271 100644 --- a/R/tm_expiring_contracts.R +++ b/R/tm_expiring_contracts.R @@ -83,6 +83,8 @@ tm_expiring_contracts <- function(country_name, contract_end_year, league_url = error = function(e) player_name <- NA_character_) player_url <- tryCatch(exp_pg %>% rvest::html_nodes(".inline-table .hauptlink a") %>% rvest::html_attr("href") %>% paste0(main_url, .), error = function(e) player_url <- NA_character_) + date_of_birth <- tryCatch(exp_pg %>% rvest::html_nodes("td.zentriert:nth-child(2)") %>% + rvest::html_text(), error = function(e) birthday <- NA_character_) position <- tryCatch(exp_pg %>% rvest::html_nodes(".inline-table tr+ tr td") %>% rvest::html_text(), error = function(e) position <- NA_character_) nationality <- tryCatch(exp_pg %>% rvest::html_nodes(".flaggenrahmen:nth-child(1)") %>% rvest::html_attr("title"), @@ -107,7 +109,7 @@ tm_expiring_contracts <- function(country_name, contract_end_year, league_url = agent <- tryCatch(exp_pg %>% rvest::html_nodes(".rechts+ .hauptlink") %>% rvest::html_text() %>% stringr::str_squish(), error = function(e) agent <- NA_character_) - out_df <- cbind(player_name, player_url, position, nationality, second_nationality, + out_df <- cbind(player_name, player_url, date_of_birth, position, nationality, second_nationality, current_club, contract_expiry, contract_option, player_market_value, transfer_fee, agent) %>% data.frame() if(is.na(league_url)) { @@ -120,6 +122,7 @@ tm_expiring_contracts <- function(country_name, contract_end_year, league_url = out_df <- out_df %>% dplyr::mutate(player_name = as.character(.data[["player_name"]]), player_url = as.character(.data[["player_url"]]), + date_of_birth = as.character(.data[["date_of_birth"]]), position = as.character(.data[["position"]]), nationality = as.character(.data[["nationality"]]), second_nationality = as.character(.data[["second_nationality"]]), From 01abd4020882ec35355442f87f19c67b50c83445 Mon Sep 17 00:00:00 2001 From: Anton <80207895+drasbaek@users.noreply.github.com> Date: Wed, 11 Sep 2024 15:17:55 +0100 Subject: [PATCH 2/3] birthday -> date of birth typo --- R/tm_expiring_contracts.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/tm_expiring_contracts.R b/R/tm_expiring_contracts.R index 46d94271..bb1f5a5c 100644 --- a/R/tm_expiring_contracts.R +++ b/R/tm_expiring_contracts.R @@ -84,7 +84,7 @@ tm_expiring_contracts <- function(country_name, contract_end_year, league_url = player_url <- tryCatch(exp_pg %>% rvest::html_nodes(".inline-table .hauptlink a") %>% rvest::html_attr("href") %>% paste0(main_url, .), error = function(e) player_url <- NA_character_) date_of_birth <- tryCatch(exp_pg %>% rvest::html_nodes("td.zentriert:nth-child(2)") %>% - rvest::html_text(), error = function(e) birthday <- NA_character_) + rvest::html_text(), error = function(e) date_of_birth <- NA_character_) position <- tryCatch(exp_pg %>% rvest::html_nodes(".inline-table tr+ tr td") %>% rvest::html_text(), error = function(e) position <- NA_character_) nationality <- tryCatch(exp_pg %>% rvest::html_nodes(".flaggenrahmen:nth-child(1)") %>% rvest::html_attr("title"), From b7c8b610d647e15bf30191520e128dcdc6dc8b29 Mon Sep 17 00:00:00 2001 From: Tony ElHabr Date: Mon, 23 Sep 2024 10:39:04 -0500 Subject: [PATCH 3/3] update description and news --- DESCRIPTION | 2 +- NEWS.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0b880663..b1fe69b4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: worldfootballR Title: Extract and Clean World Football (Soccer) Data -Version: 0.6.6.0000 +Version: 0.6.6.0001 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 0e5124d5..6327c6b2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,8 @@ ### Improvements +* `tm_expiring_contracts()` returns additional `date_of_birth` column. (0.6.6.0001) [#355](https://github.com/JaseZiv/worldfootballR/issues/397) + *** # worldfootballR 0.6.6