Search code examples
javascriptrweb-scraping

Exporting citation of a journal article using R


I want R to:

  1. Go THIS page.
  2. Select "Bibtex" as Format, "Citation and Abstract" for "Export type".
  3. Press "Submit" and download the citation file to a designated folder.

Is it possible? How can I do that with R? (I don't know JavaScript and I couldn't understand earlier topics much related to this issue. 1, 2, 3)

Eventually, I want to download all bibtex (and possibly Endnote) citations of a journal (for example THIS journal).


Solution

  • You can fake a form submission with the httr package. For this request you could do

    values <- list(
        doi = "10.1002%2Fasi.21577",
        fileFormat = "BIBTEX",
        hasAbstract = "CITATION_AND_ABSTRACT"
    )
    
    library(httr)
    url <- "http://onlinelibrary.wiley.com/documentcitationdownloadformsubmit"
    rr <- POST(url=url, body=values, encode="form")
    content(rr, "text")
    # [1] "@article {ASI:ASI21577,\nauthor = {Callahan, Ewa S. ...