from Bio import Entrez
from pubmed_mapper import Article
Entrez.email = "123@example.com"
import re
def name(ab):
t=[]
for i in ab:
a = str(i).split()
del a[1]
b = " ".join(a)
t.append(b)
c=",".join(t)
return c
def huoqu(can):
article = Article.parse_pmid(can)
PubMedID = article.pmid
Doilist = article.ids
Title = article.title
Abstract = article.abstract
Keywords = article.keywords
Journal = article.journal
Authors = article.authors
Pubdate = article.pubdate
c = {i.id_type: i.id_value for i in Doilist}
Doi = c.get('doi')
Author=name(Authors)
Ino = [Title, Doi, Journal, Author, Pubdate]
return Ino
keyword=input('关键词:')
handle = Entrez.esearch(db='pubmed', term=keyword, retmax=10)
record = Entrez.read(handle)
handle.close()
pmids = record["IdList"]
print(pmids)
for i in pmids:
print(huoqu(i))