所以这个工作得很好,但record.get( “SO”), “?”)只返回该杂志
没有的缩写它没有。它甚至不会因这条线运行:
records = list(records)
为records
没有定义。即使你解决这个问题,你得到回:
idlist = record["IdList"]
就像号码清单:即旨在传递通过Entrez.efetch()
回调得到实际数据['17510654', '2246389']
。所以当你在这些数字串中的一个上做record.get("SO", "?")
时,你的代码就会再次出现。
首先,"SO"
字段缩写定义为返回期刊标题缩写(TA)作为其返回的一部分。您可能需要使用"JT"
Journal Title,而不是MEDLINE/PubMed Data Element (Field) Descriptions中定义的。但是这些都与这个查询没有任何关系。
这是你的代码的返工,以获得文章的标题,它是在该杂志的标题:
from Bio import Entrez
Entrez.email = "[email protected]" # change this to be your email address
handle = Entrez.esearch(db="pubmed", term="cancer AND wombats", retmax=20)
record = Entrez.read(handle)
handle.close()
for identifier in record['IdList']:
pubmed_entry = Entrez.efetch(db="pubmed", id=identifier, retmode="xml")
result = Entrez.read(pubmed_entry)
article = result['PubmedArticle'][0]['MedlineCitation']['Article']
print('"{}" in "{}"'.format(article['ArticleTitle'], article['Journal']['Title']))
输出
> python3 test.py
"Of wombats and whales: telomere tales in Madrid. Conference on telomeres and telomerase." in "EMBO reports"
"Spontaneous proliferations in Australian marsupials--a survey and review. 1. Macropods, koalas, wombats, possums and gliders." in "Journal of comparative pathology"
>
详细信息可以在文档中找到: MEDLINE PubMed XML Element Descriptions