我想摘录这个回复的内容:
<div class="bio-container">
<p class="bio profile" >
Chinedu is a good boy
</p>
</div>
请假设还有其他paragrpah标记具有不同的类属性,但我想用class属性“bio profile”提取这个标签
我只是想提取一个好文件。在
我试过desc = bs.find ('p', {'class' : 'bio profile'})
但不起作用
我正试图将上述答案应用于:
^{pr2}$但我得到了一个错误陈述
print desc.get_text().strip()
AttributeError: 'NoneType' object has no attribute 'get_text'
使用BeautifulGroup模块从
<p>
标记提取所有文本。在内容脚本.py:
运行方式如下:
^{pr2}$试试这个
您应该对
desc
使用.get_text()
方法。使用Python 2.7和BS 4.3.2:结果:
^{pr2}$希望这有帮助。在
相关问题 更多 >
编程相关推荐