Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bibliovid
scrappers
Commits
a70841cb
Commit
a70841cb
authored
Jun 12, 2020
by
Benoit Favre
Browse files
fix problems with pubmed servers disconnecting
parent
8f9d71d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
bibliovid_add_abstract.py
View file @
a70841cb
...
...
@@ -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,16 +34,22 @@ 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
)]:
results
=
pubmed
.
query
(
query
,
max_results
=
30
)
for
result
in
results
:
entry
=
result
.
toDict
()
if
normalize
(
title
)
==
normalize
(
entry
[
'title'
]):
found
=
True
for
field
in
[
'pubmed_id'
,
'doi'
,
'abstract'
]:
if
field
in
entry
:
article
[
field
]
=
entry
[
field
]
stats
[
field
]
+=
1
for
retries
in
range
(
10
):
try
:
results
=
pubmed
.
query
(
query
,
max_results
=
30
)
for
result
in
results
:
entry
=
result
.
toDict
()
if
normalize
(
title
)
==
normalize
(
entry
[
'title'
]):
found
=
True
for
field
in
[
'pubmed_id'
,
'doi'
,
'abstract'
]:
if
field
in
entry
:
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
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment