我需要自动化的PubMed文章收割。我只找到了按术语查询下载PubMed文章和按pmid下载PubMed文章的示例。(一篇文章)但我正在考虑的是按日期(从-到)下载一个PubMed in列表,或者所有它们,就像在OAI中一样。
发布于 2016-06-16 21:05:21
您可以使用BioPython来实现这些目的。下面的代码片段将为您提供某个日期范围内所有PubMed文章的链接。PMC文章可以直接下载,对于其他文章,会提供DOI,但PDF的位置是特定于出版商的,不能预测所有文章的位置。
def article_links(start_date, end_date = '3000'):
"""
start_date, end_date = 'YYYY/MM/DD'
returns a list of PubMedCentral links and a 2nd list of DOI links
"""
from Bio import Entrez
Entrez.email = "Your.Name.Here@example.org"
#get all articles in certain date range, in this case 5 articles which will be published in the future
handle = Entrez.esearch(db="pubmed", term='("%s"[Date - Publication] : "%s"[Date - Publication]) ' %(start_date, end_date))
records = Entrez.read(handle)
#get a list of Pubmed IDs for all articles
idlist = ','.join(records['IdList'])
handle = Entrez.efetch("pubmed", id=idlist, retmode="xml")
records = Entrez.parse(handle)
pmc_articles = []
doi = []
for record in records:
#get all PMC articles
if record.get('MedlineCitation'):
if record['MedlineCitation'].get('OtherID'):
for other_id in record['MedlineCitation']['OtherID']:
if other_id.title().startswith('Pmc'):
pmc_articles.append('http://www.ncbi.nlm.nih.gov/pmc/articles/%s/pdf/' % (other_id.title().upper()))
#get all DOIs
if record.get('PubmedData'):
if record['PubmedData'].get('ArticleIdList'):
for other_id in record['PubmedData']['ArticleIdList']:
if 'doi' in other_id.attributes.values():
doi.append('http://dx.doi.org/' + other_id.title())
return pmc_articles, doi
if __name__ == '__main__':
print (article_links('2016/12/20'))https://stackoverflow.com/questions/37539333
复制相似问题