尝试查找网站上的最大页面数。
https://www.reconciliation.org.au/reconciliation-action-plans/who-has-a-rap/
我在以下方面遵循了代码/教程: https://www.datacamp.com/community/tutorials/r-web-scraping-rvest
url <-'https://www.reconciliation.org.au/reconciliation-action-plans/who-has-a-rap/'
get_last_page <- function(html){
pages_data <- html %>%
# The '.' indicates the class
html_nodes('.pagination-max-pages') %>%
# Extract the raw text as a list
html_text()
#The second to last of the buttons is the one
pages_data[(length(pages_data)-1)] %>%
# Take the raw string
unname() %>%
# Convert to number
as.numeric()
}
first_page <- read_html(url)
(latest_page_number <- get_last_page(first_page))
结果显示数字(0) 而不是46