在BeautifulSoup中是否有InnerText等效项? [英] Is there an InnerText equivalent in BeautifulSoup?

查看:302
本文介绍了在BeautifulSoup中是否有InnerText等效项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用以下代码:

soup = BeautifulSoup(page.read(), fromEncoding="utf-8")
result = soup.find('div', {'class' :'flagPageTitle'})

我得到以下html:

<div id="ctl00_ContentPlaceHolder1_Item65404" class="flagPageTitle" style=" ">
<span></span><p>Some text here</p>
</div>

如何获取没有任何标签的Some text here? BeautifulSoup中是否有InnerText等效项?

How can I get Some text here without any tags? Is there InnerText equivalent in BeautifulSoup?

推荐答案

您需要的是:

result = soup.find('div', {'class' :'flagPageTitle'}).text

这篇关于在BeautifulSoup中是否有InnerText等效项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆