【发布时间】:2021-03-14 18:31:23
【问题描述】:
我有一个这种格式的 BeautifulSoup
<div class='text'>
<h3> text </h3>
<p> some more text </p>
"text here <b> is </b> important"
</div>
如何仅提取字符串“此处的文本很重要”,省略 h3 和 p 元素,但粗体标记文本保留在输出中
非常感谢
【问题讨论】:
-
是用正则表达式可接受的解决方案解析这个字符串吗? (re.findall(r'"[^"]+.',your_string))
标签: python web-scraping beautifulsoup