core_articles_pdf: Download article pdf

View source: R/core_articles_pdf.R

core_articles_pdfR Documentation

Download article pdf

Description

Download article pdf

Usage

core_articles_pdf(id, key = NULL, overwrite = FALSE, ...)

core_articles_pdf_(id, key = NULL, overwrite = FALSE, ...)

Arguments

id

(integer) CORE ID of the article that needs to be fetched. One or more. Required

key

A CORE API key. Get one at https://core.ac.uk/api-keys/register. Once you have the key, you can pass it into this parameter, or as a much better option, store your key as an environment variable with the name CORE_KEY or an R option as core_key. See ?Startup for how to work with env vars and R options

overwrite

(logical) overwrite file or not if already on disk. Default: FALSE

...

Curl options passed to crul::HttpClient()

Details

core_articles_pdf does the HTTP request and parses PDF to text, while core_articles_pdf_ just does the HTTP request and gives back the path to the file

If you get a message like Error: Not Found (HTTP 404), that means a PDF was not found. That is, it does not exist. That is, there is no PDF associated with the article ID you searched for. This is the correct behavior, and nothing is wrong with this function or this package. We could do another web request to check if the id you pass in has a PDF or not first, but that's another request, slowing this function down.

Value

core_articles_pdf_ returns a file path on success. When many IDs passed to core_articles_pdf it returns a list (equal to length of IDs) where each element is a character vector of length equal to number of pages in the PDF; but on failure throws warning and returns NULL. When single ID apssed to core_articles_pdf it returns a character vector of length equal to number of pages in the PDF, but on failure stops with message

References

https://core.ac.uk/docs/#!/articles/getArticlePdfByCoreId

Examples

## Not run: 
# just http request, get file path back
core_articles_pdf_(11549557)

# get paper and parse to text
core_articles_pdf(11549557)

ids <- c(11549557, 385071)
res <- core_articles_pdf(ids)
cat(res[[1]][1])
cat(res[[2]][1])

## End(Not run)

ropenscilabs/cored documentation built on Sept. 12, 2022, 3:13 p.m.