danielnsilva / semanticscholar

Unofficial Python client library for Semantic Scholar APIs.
MIT License
304 stars 40 forks source link

Is it possible to download PDFs? #94

Closed MatteoRiva95 closed 1 hour ago

MatteoRiva95 commented 1 week ago

Question

Hello everyone,

I would like to know if there is a method to download PDFs using DOIs. If yes, can you tell me how, please?

Thank you so much in advance!

danielnsilva commented 1 week ago

Hello @MatteoRiva95. Try this:

from semanticscholar import SemanticScholar
import urllib.request
sch = SemanticScholar()
paper = sch.get_paper('10.1079/9781845939649.0000')
if paper.isOpenAccess:
    urllib.request.urlretrieve(paper.openAccessPdf['url'], "paper.pdf")
danielnsilva commented 1 hour ago

Closing this for now. Feel free to reopen anytime.