python爬虫pubmed论文标题

很少有人爬pubmed的,我来填个空,直接上干货。

import requests
import re
content=input('请输入内容:')
url1 = 'https://www.ncbi.nlm.nih.gov/pubmed/?term='+content
html=requests.get(url1).text
pat='linksrc=docsum_title">(.*?).</a></p><div class'
title1=re.findall(pat,html,re.S)
title2=[i.replace('<b>','') for i in title1]
title3=[[title2[i]] for i in range(len(title1))]
print(title3[0])

执行后,输入要搜索的关键词,因为是国外的网站,关键词必须是英文哦,例如melanin,然后回车,这里只显示第一个论文的标题,

请输入内容:melanin
['Molecular characterization of SLC24A5 variants and evaluation of Nitisinone treatment efficacy in a zebrafish model of OCA6']

要是不喜欢看英文,是否可以将英文直接翻译成汉语并显示出来?
期待下一篇文档。。。。。。。

猜你喜欢

转载自blog.csdn.net/R_python/article/details/105469353
今日推荐