我正试图爬过ncbi eutils webpage。我想从web上抓取Id列表,如下所示:
代码如下:
import requests
from bs4 import BeautifulSoup
def get_html(url):
"""get the content of the url"""
response = requests.get(url)
response.encoding = 'utf-8'
return response.text
def get_pmid(html):
soup = BeautifulSoup(html, 'lxml')
for texts in soup.select('body'):
text = texts.get_text()
print text
url_ncbi = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=%22D-PANTOTHENIC+ACID%22&retmax=2000&usehistory=y&field=Title/Abstracts"
html = get_html(url_ncbi)
get_pmid(html)
我想使用select函数来获取文本,但找不到脚本的正确代码:soup.select(' ')
中的文本。你知道吗
我被web代码中的多层类和ID弄糊涂了,比如:
要获取所有
ID
标记,可以使用find_all()
函数:印刷品:
相关问题 更多 >
编程相关推荐