#extract fields
rank <- page %>%
html_elements(".number") %>%
html_text(trim = TRUE) # get text, remove spaces
title <- page %>%
html_elements(".bookTitle span") %>%
html_text(trim = TRUE)
author_name <- page %>%
html_elements(".authorName span") %>%
html_text(trim = TRUE) %>%
gsub(",", "", .) # replace commas with nothing
score <- page %>%
html_elements(".uitext a:nth-child(1)") %>%
html_text(trim = TRUE) %>%
gsub("score:", ",", .) %>%
gsub(",", "", .)
#make data frame
books_df <- tibble(
rank = rank,
title = title,
author_name = author_name,
score = score
)
books_df