相关疑难解决方法(0)

获取没有内部子标签文本的HTML标签文本

例:

有时HTML是:

<div id="1">
    <div id="2">
        this is the text i do NOT want
    </div>
    this is the text i want here
</div>
Run Code Online (Sandbox Code Playgroud)

其他时候它只是:

<div id="1">
    this is the text i want here
</div>
Run Code Online (Sandbox Code Playgroud)

我想只获取一个标签中的文本,并忽略所有其他子标签.如果我经营这家.text酒店,我会得到两个.

python beautifulsoup python-2.7

3
推荐指数
2
解决办法
3985
查看次数

标签 统计

beautifulsoup ×1

python ×1

python-2.7 ×1