【发布时间】:2019-11-12 00:18:55
【问题描述】:
我有一个 html 数据,我只想提取粗体字体类型的文本。
<span style="font-family: ABCDEE+Cambria,Bold; font-size:9px">Pinecone Functions
<br></span></div><div style="position:absolute; border: textbox 1px solid; writing-mode:lr-tb; left:419px; top:1903px; width:76px; height:11px;"><span style="font-family: ABCDEE+Calibri,Bold; font-size:7px">Trainee Sign-Off
<br></span></div>
我只想要字体系列下的文本:ABCDEE+Cambria, Bold。
with open('/home/output4.html') as file:
text = file.read()
soup = BeautifulSoup(text, 'html.parser')
x = soup.find_all('span', style=re.compile(r'font-family: ABCDEE+Cambria,Bold.*'))
for rows in x:
print(rows.text)
我试过这个 bt 结果是空列表。
【问题讨论】:
-
可能还会显示您尝试解析/提取的 html 示例
标签: python html regex beautifulsoup html-parsing