I am trying to scrape the tables from the following link: https://www.mlbdraftleague.com/mahoning-valley/roster
library(rvest)
library(magrittr)
url <- "https://www.mlbdraftleague.com/mahoning-valley/roster"
page <- read_html(url) %>%
html_table(fill = T)
I tried that and it returned empty Dfs with the right amount of tables (5) and the right amount of columns, but the dataframes are empty. All help is appreciated.
library(tidyverse)
library(httr2)
"https://statsapi.mlb.com/api/v1/teams/545/roster?hydrate=person(rosterEntries,education,stats(type=season,season=2023,sportId=22,teamId=545))&rosterType=active&season=2023&sportId=22" %>%
request() %>%
req_perform() %>%
resp_body_json(simplifyVector = TRUE) %>%
pluck("roster") %>%
unnest(everything(), names_sep = "_")
# A tibble: 41 × 47
person_id person_full_name person_link person_first_name person_last_name person_birth_date person_current_age person_birth_city person_birth_state_p…¹
<int> <chr> <chr> <chr> <chr> <chr> <int> <chr> <chr>
1 813834 AJ Rausch /api/v1/peop… AJ Rausch 2002-03-19 21 Powell OH
2 800677 Ahmad Harajli /api/v1/peop… Ahmad Harajli 2001-08-31 21 Dearborn MI
3 701144 Alex Shea /api/v1/peop… Brian Shea 2001-05-04 22 Union KY
4 701475 Andreaus Lewis /api/v1/peop… Andreaus Lewis 2002-12-10 20 Atlanta GA
5 701499 Andrew Lucas /api/v1/peop… Andrew Lucas 2000-02-04 23 Camarillo CA
6 813836 Braeden O'Shaughnessy /api/v1/peop… Braeden O'Shaughnessy 2000-11-19 22 Poland OH
7 681376 Brandon Hylton /api/v1/peop… Brandon Hylton 2000-02-01 23 Livingston NJ
8 695480 Brennyn Abendroth /api/v1/peop… Brennyn Abendroth 2003-06-07 20 Effingham IL
9 695746 Cale Lansville /api/v1/peop… Cale Lansville 2003-01-06 20 Englewood CO
10 809953 Cam Liss /api/v1/peop… Cameron Liss 2000-04-15 23 Spokane WA
# ℹ 31 more rows