1 min read

An update to "An adventure in downloading books"

I received an email from Bernardo Lares as feedback on my previous article. You can also view some of the other cool work done by him in this link.

His script is provided below. He uses the rvest package and the %>% operator to keep it really short and simple.

library(rvest)
library(dplyr)
library(stringr)

list <- "https://towardsdatascience.com/springer-has-released-65-machine-learning-and-data-books-for-free-961f8181f189"
aux <- read_html(list) %>%
  html_node("div") %>%
  html_text() %>%
  str_split("http://link.springer.com/openurl\\?genre=book&isbn=")
ids <- substr(unlist(aux), 1, 17)[-1]
sapply(ids, function(x) {
  url <- paste0("https://link.springer.com/content/pdf/10.1007%2F", x, ".pdf")
  download.file(url, paste0(x, ".pdf"), mode = "wb")
})