Skip to content

Commit

Permalink
add repeated DOI ping
Browse files Browse the repository at this point in the history
  • Loading branch information
eddotman committed Dec 23, 2015
1 parent f86b950 commit 8a04b63
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
24 changes: 14 additions & 10 deletions articledownloader/articledownloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,23 @@ def get_dois_from_search(self, query, rows=500):
else: #Need to split queries
stop_query = False
cursor = '*'

while not stop_query:
try:
search_url = base_url + query + '&rows=' + str(max_rows) + '&cursor=' + cursor
response = requests.get(search_url, headers=self.headers).json()
cursor = response['message']['next-cursor']
stop_ping = False
search_url = base_url + query + '&rows=' + str(max_rows) + '&cursor=' + cursor

if len(response["message"]["items"]) < max_rows or len(dois) >= rows:
stop_query = True
while not stop_ping:
response = requests.get(search_url, headers=self.headers)
if response.status_code == 200:
j_response = response.json()
cursor = response['message']['next-cursor']
stop_ping = True

for item in response["message"]["items"]:
dois.append(item["DOI"])
except:
return list(set(dois))
if len(response["message"]["items"]) < max_rows or len(dois) >= rows:
stop_query = True

for item in response["message"]["items"]:
dois.append(item["DOI"])

return list(set(dois))

Expand Down
Binary file added dist/articledownloader-3.1.tar.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
setup(
name = 'articledownloader',
packages = ['articledownloader'], # this must be the same as the name above
version = '3.0',
version = '3.1',
description = 'A class for downloading scientific journal articles',
author = 'Edward Kim',
author_email = 'eddotman@gmail.com',
url = 'https://github.com/eddotman/article-downloader', # use the URL to the github repo
download_url = 'https://www.github.com/eddotman/article-downloader/tarball/3.0',
download_url = 'https://www.github.com/eddotman/article-downloader/tarball/3.1',
keywords = ['journal', 'paper', 'article', 'downloader'], # arbitrary keywords
)

0 comments on commit 8a04b63

Please sign in to comment.