Skip to content

Instantly share code, notes, and snippets.

@trinker
Last active October 12, 2018 11:44
Show Gist options
  • Save trinker/4ccc9df173dc73c36c1b3c6dff3c42ed to your computer and use it in GitHub Desktop.
Save trinker/4ccc9df173dc73c36c1b3c6dff3c42ed to your computer and use it in GitHub Desktop.
R Guttenberg API
## Originally taken from: https://juliasilge.github.io/ibm-ai-day/slides.html#1
if (!require("pacman")) install.packages("pacman")
pacman::p_load(tidyverse, gutenbergr)
## Scrape known books
titles <- c(
"Twenty Thousand Leagues under the Sea",
"The War of the Worlds",
"Pride and Prejudice",
"Great Expectations"
)
books <- gutenberg_works(title %in% titles) %>%
gutenberg_download(meta_fields = "title")
books
## Scrape fuzzy matched books
bibles <- gutenberg_works(grepl('bible', title, ignore.case = TRUE)) %>%
gutenberg_download(meta_fields = "title")
bibles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment