I'm trying to scrape tables of data from different pages on fbref.com using rvest. I've been able to scrape the data from one page using:
library(rvest)
URL <- "https://fbref.com/en/squads/822bd0ba/Liverpool"
WS <- read_html(URL)
passStats <- WS %>% rvest::html_nodes(xpath = '//*[(@id = "ks_sched_all")]') %>% rvest::html_table() %>% data.frame()
but when I try to apply it to multiple pages using a for loop I have a problem as not all of the pages use the same id for the table. Some are "ks_sched_all" but others are "ks_sched_(4-digit number)". Is there any way to just extract any table on the page with an id starting with: "ks_sched_"?