Skip to content

Commit 4df50d5

Browse files
authored
fix: update DOI extraction path (#9)
1 parent e1bf5ac commit 4df50d5

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

pymed_paperscraper/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from .api import PubMed
22

33
__all__ = ["PubMed"]
4-
__version__ = "1.0.4"
4+
__version__ = "1.0.5"

pymed_paperscraper/article.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def _extractCopyrights(self: object, xml_element: TypeVar("Element")) -> str:
8181
return getContent(element=xml_element, path=path)
8282

8383
def _extractDoi(self: object, xml_element: TypeVar("Element")) -> str:
84-
path = ".//ArticleId[@IdType='doi']"
84+
path = ".//PubmedData/ArticleIdList/ArticleId[@IdType='doi']"
8585
return getContent(element=xml_element, path=path)
8686

8787
def _extractPublicationDate(

pymed_paperscraper/tests/test_article.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,15 @@ def test_unique_id():
88

99
for r in results:
1010
ids = r.pubmed_id.strip().split("\n")
11-
assert len(ids) == 1
11+
assert len(ids) == 1
12+
13+
def test_unique_doi():
14+
pubmed = PubMed(tool="MyTool", email="my@email.address")
15+
query = '((Haliaeetus leucocephalus[Title/Abstract])) AND ((prey[Title/Abstract]) OR (diet[Title/Abstract]))'
16+
results = pubmed.query(query, max_results=30)
17+
18+
for r in results:
19+
if r.doi is None:
20+
continue
21+
dois = r.doi.strip().split("\n")
22+
assert len(dois) == 1

0 commit comments

Comments
 (0)