Получение максимального числа страниц - PullRequest
0 голосов
/ 27 июня 2019

Попытка найти максимальное количество страниц на сайте.

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

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...