Python BS4 CSS选择器提取文本 - 使用.select()获取红圈标签并提取文本
from bs4 import BeautifulSoup
html = '''
标题1
段落1
标题2
段落2
soup = BeautifulSoup(html, 'html.parser') tag = soup.select('.red') text = tag[0].get_text()
print(text)
原文地址: https://www.cveoy.top/t/topic/pibg 著作权归作者所有。请勿转载和采集!