knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
Access the Library of Congress from R.
Chronicling America provides access [140,000] historic newspapers and select digitized newspaper pages.
# install.packages("remotes") remotes::install_github("news-r/loc")
library(loc) # titles titles <- loc_search_titles("michigan", pages = 2) # pages (articles <- loc_search_pages("Thomas"))
The text of the newspaper is in the ocr_eng
variable. You can reconstruct endpoints to specific newspapers, editions, or issues.
a <- sample(articles$url, 1) # take a random article pdf <- gsub(".json", ".pdf", a) # change to PDF # browseURL(pdf)
And you can get the text with:
txt <- gsub(".json", "/ocr.txt", a) # change to PDF readLines(txt)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.