Hi Community
Im want scrape this 9 pages, only change the number in the link page=
. If I see well, the table node is the same for all pages.
Im try with glue
but dont run well
library(tidyverse, warn.conflicts = F)
library(rvest, warn.conflicts = F)
library(xml2)
url_dat<- "https://opengovca.com/alberta-child-care?page="
for ( i in 1:9){
reddit_ex <- paste0("https://opengovca.com/alberta-child-care?page=", i) %>%
read_html() %>%
html_nodes(xpath = paste('//html/body/div[1]/div/div[2]/div[3]/div[2]/table')) %>%
html_table() |>
data.frame()
reddit_ex$pagina <- i
}
# This show the results only the 9 page, the others are not showed
# ###### other example:
startTime <- Sys.time()
get_cg <- function(pages) {
cat("Scraping page", pages, "\n")
page <-
paste0("https://opengovca.com/alberta-child-care?page=", pages) %>%
read_html()
html_nodes(xpath = '//html/body/div[1]/div/div[2]/div[3]/div[2]/table') %>%
html_table() |>
data.frame()
}
# Get this error
# Error in xml2::xml_find_all(x, make_selector(css, xpath)) :
# argument "x" is missing, with no default
df <- map_dfr(1, get_cg)
Tnks!