Simple unofficial library to send requests to the unpaywall API ( http://unpaywall.org/products/api ) and automatically download documents.
"Yes! We harvest content from legal sources including repositories run by universities, governments, and scholarly societies, as well as open content hosted by publishers themselves." (source, April 28, 2018)
Both Methods are also available for multiple requests / downloads (see godoc), which will be executed concurrently. By default 5 workers are started simultaneously.
// your email address
var email string
// DOI
var doi string
u, _ := unpaywall.New(email)
// Request example
result, err := u.RequestByDOI(doi)
if err != nil {
log.Fatalf("Error: %v", err)
}
fmt.Printf("Search result: %v", result)
// your email address
var email string
// DOI
var doi string
u, _ := unpaywall.New(email)
var targetPath = "./"
file, err := u.DownloadByDOI(doi, targetPath)
if err != nil {
log.Fatalf("Error: %v", err)
}
log.Printf("Success! Downloaded file to %s", file)
// your email address
var email string
//DOIs
var dois []string
u, _ := unpaywall.New(email)
res, err := u.RequestByDOIs(dois)
for err != nil || res != nil {
select {
case r, ok := <-res:
if !ok {
res = nil
continue
}
fmt.Printf("Found: %s \n", r.BestOaLocation.URLForPdf)
case e, ok := <-err:
if !ok {
err = nil
continue
}
fmt.Printf("Error: %s \n", e)
}
}
The CLI tool in the cmd
folder can be used like this:
unpaywall-cmd -doi "your-DOI" -email "your-email-address"