Python to download pdf full papers from sciencedirect or scopus via api

974 views Asked by At

I am trying to batch-load papers from scopus (sciencedirect) via api.

  • The code below works for doi1, successfully 1st page only (maybe the paper is not open-access).
  • I tried many other doi, like doi2, but always error 404 (not found).
  • I tried using eid, same error 404, although it states it should, here
  • I tried using the code from here too, exactly same (doi1 gave 1st page, others gave error)

Thanks for any help!

    headers = {
        'X-ELS-APIKEY': "keykeykeykeykeykey",
        'Accept': 'application/pdf',
        'X-ELS-Insttoken': "instToken",
        'view' = 'FULL'
    }

    _url_base= u'https://api.elsevier.com/content/article/'

    # doi2 = '10.1038/s41598-022-13702-3' # open
    # doi2 = '10.1038/s43586-022-00095-w' # no open
    # doi2 = '10.1016/0038-1098(87)90044-5'
    # doi2 = '10.1038/s41467-022-28902-8'
    doi1 = '10.1016/S1525-1578(10)60571-5'
    url = _url_base + 'doi/' + str(doi1)
    
    # eid = '2-s2.0-0023361241'
    # url = _url_base + 'eid/' + str(eid) 
    print(url)
    
    res = requests.get(url, headers = headers)
    print(res.status_code)
    if res.status_code == 200:
        with open('test1' + '.pdf','wb') as f:
            f.write(res.content)
0

There are 0 answers