我想获取特定期刊中与特定术语/主题相关的所有文章。
我正在尝试使用Biopython中包含的Entrez软件包通过PubMed这样做。 相应的高级PubMed搜索为: (主题/术语)和“期刊名称” [Journal]
到目前为止,我所尝试的是基于Marco Bonzanini编写的代码(GitHub页面包含原始代码https://gist.github.com/bonzanini/5a4c39e4c02502a8451d)。
from Bio import Entrez
def search(query):
Entrez.email = 'example@mail.com'
handle = Entrez.esearch(db='pubmed',
sort='relevance',
retmax='20',
retmode='xml',
term=query,
mindate= "2018/11",
maxdate= "2019/02")
results = Entrez.read(handle)
return results
def fetch_details(id_list):
ids = ','.join(id_list)
Entrez.email = 'example@mail.com'
handle = Entrez.efetch(db='pubmed',
retmode='xml',
id=ids)
results = Entrez.read(handle)
return results
if __name__ == '__main__':
results = search('attention')
id_list = results['IdList']
papers = fetch_details(id_list)
for i, paper in enumerate(papers['PubmedArticle']):
print("%d) %s" % (i + 1, paper['MedlineCitation']['Article']['ArticleTitle']))
答案 0 :(得分:0)
例如寻找出现在《实验儿童心理学杂志》上的文章,像这样改变您的主体:
if __name__ == '__main__':
results = search('attention')
id_list = results['IdList']
papers = fetch_details(id_list)
i = 0
for paper in papers['PubmedArticle']:
if (paper['MedlineCitation']['Article']['Journal']['Title'] ==
'Journal of experimental child psychology'):
i += 1
print("%d) %s" % (i, paper['MedlineCitation']['Article']
['ArticleTitle']))