Skip to content
Snippets Groups Projects
Commit a70841cb authored by Benoit Favre's avatar Benoit Favre
Browse files

fix problems with pubmed servers disconnecting

parent 8f9d71d4
Branches
No related tags found
No related merge requests found
......@@ -5,6 +5,8 @@ import sys, json, re, collections
from pymed import PubMed
from datetime import datetime, date
import requests
import time
pubmed = PubMed(tool="https://covid19.lis-lab.fr", email="benoit.favre@univ-amu.fr")
......@@ -32,6 +34,8 @@ for article in articles['results']:
found = False
for query in ['(%s[Title] AND (%s[Author])' % (preprocess(title), preprocess(authors)), '%s[Title]' % preprocess(title), preprocess(title)]:
for retries in range(10):
try:
results = pubmed.query(query, max_results=30)
for result in results:
entry = result.toDict()
......@@ -42,6 +46,10 @@ for article in articles['results']:
article[field] = entry[field]
stats[field] += 1
break
break
except requests.exceptions.HTTPError as e:
print(e, file=sys.stderr)
time.sleep(5)
if found:
break
if not found:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment