我试图把一个静态新闻网站作为一个项目,我正在使用美丽的汤,但我被困在一个页面,其中包含文本在div标签,这里文本意味着新闻文章
新闻文本采用以下格式
<html>
<body>
<div class="normal" id="foo">
" Many "
<a href ='/some link' target = 'blank'>Bollywood</a>
" stars today are avowed foodies "
<a href = 'link2'>Ranbir Kapoor</a>
" Alia Bhat "
</div>
</body>
</html>
我想要的文字是“今天许多宝莱坞明星都是誓言的美食家。Alia Bhat“
那就是我想要所有的文本,不管它们在哪里。在
我可以使用find_all('div','normal')在div进行驱动,但是在那之后,我还是坚持了如何从页面检索所有文本元素。在
如果你想知道更多信息,请告诉我。在
要从beautifulGroup中的某个元素提取
text
,可以使用.text
属性:相关问题 更多 >
编程相关推荐