我目前正在写一个程序,它需要我从NCBI上抓取文章。
我正在使用Entrez Utilities来做这件事(https://www.ncbi.nlm.nih.gov/books/NBK25497/)。
我已经知道了如何使用handle = Entrez.efetch(db='pubmed', id=pmid, retmode='text', rettype='abstract')
来处理PubMed数据。
但是,我想从NCBI的books部分抓取数据,因为pubmed部分包含不完整的文章(例如,比较https://pubmed.ncbi.nlm.nih.gov/20301533/与https://www.ncbi.nlm.nih.gov/books/NBK1359/)。
我有一个所有GeneReviews ID的列表(例如NB1359、NB1400等)但是我不知道如何抓取这些数据,因为handle = Entrez.esearch(db='books', term="NB1359", retmode='text')
不会返回文章中的文本。
发布于 2020-07-29 22:06:40
我也看不到使用Entrez.esearch
的方法,但我会直接下载页面的可打印版本并进行解析:
import requests
from bs4 import BeautifulSoup
genereview_ids = ['NBK1359', 'NBK1400']
for genereview_id in genereview_ids:
url = f"https://www.ncbi.nlm.nih.gov/books/{genereview_id}/?report=printable"
r = requests.get(url)
html_doc = r.text
soup = BeautifulSoup(html_doc, 'html.parser')
print(soup.find('meta', {'name': 'description'})['content'])
输出:
The purpose of this overview is to increase the awareness of clinicians regarding congenital diaphragmatic hernia and its genetic causes and management.
Cystinosis comprises three allelic phenotypes:
https://stackoverflow.com/questions/62717165
复制相似问题