我有一个html文本如下
<h2 class="ArticleBody-styles-makeit-subtitle--LnHeO">1. Python</h2>
通过使用Beautiful Soup,我们如何提取1. Python
文本
我正在努力
data = [ <h2 class="ArticleBody-styles-makeit-subtitle--LnHeO">1. Python</h2> ,
<h2 class="ArticleBody-styles-makeit-subtitle--LnHeO">2. HTML</h2> ]
for item in data :
text = item.findAll('h2')
print(text.get_text())
非常感谢您的建议
我删除了
item.findAll('h2')
并修改如下现在很好用
相关问题 更多 >
编程相关推荐