Skip to content

Commit

Permalink
added springer downloaders
Browse files Browse the repository at this point in the history
  • Loading branch information
eddotman committed Dec 1, 2015
1 parent 9a20167 commit 318cfaa
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion articledownloader/articledownloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def get_pdf_from_doi(self, doi, writefile, mode):
:param writefile: file object to write to
:type writefile: file
:param mode: either 'crossref' or 'elsevier', depending on how we wish to access the file
:param mode: either 'crossref' | 'elsevier' | 'rsc' | 'springer', depending on how we wish to access the file
:type mode: str
:returns: True on successful write, False otherwise
Expand Down Expand Up @@ -155,6 +155,21 @@ def get_pdf_from_doi(self, doi, writefile, mode):

return False

if mode == 'springer':
base_url = 'http://link.springer.com/'
api_url = base_url + doi + '.pdf'

try:
self.headers['Accept'] = 'application/pdf'
r = requests.get(api_url, stream=True, headers=self.headers)
if r.status_code == 200:
for chunk in r.iter_content(2048):
writefile.write(chunk)
return True
except:
return False
return False

@traced
def get_abstract_from_doi(self, doi, mode):
'''
Expand Down

0 comments on commit 318cfaa

Please sign in to comment.