【发布时间】:2020-06-05 00:39:24
【问题描述】:
结构是这样的
<div>
<div>some text</div>
<div>some text</div>
98
</div>
如何通过 BeautifulSoup 仅获取 '98' 忽略其他嵌套 div 中的文本
一段代码:
<div class="b-stickiness js-stickiness">
<div class="b-stickiness__ico">
<svg class="sc-icon" data-group="xs" data-name="ChartPie" fill="currentColor" height="12" preserveaspectratio="xMidYMid meet" viewbox="0 0 12 12" width="12">
<path d="M6 1v5h5c0-2.761-2.239-5-5-5zm-1 1c-2.761 0-5 2.239-5 5s2.239 5 5 5 5-2.239 5-5h-5v-5z" shape-rendering="geometricPresision">
</path>
</svg>
<div class="b-stickiness__tooltip js-tooltip">
<div class="b-stickiness__tooltip__inner">
<div class="b-stickiness__tooltip__title">
Wow-Score
</div>
<div class="b-stickiness__tooltip__text">
The Wow-Score shows how engaging a blog post is. It is calculated based on the correlation between users’ active reading time, their scrolling speed and the article’s length.
</div>
<a class="b-stickiness__tooltip__btn js-stickiness-btn" data-type="min" href="/wow-score/about/" title="Learn more">
Learn more
</a>
</div>
</div>
</div>
99
</div>
我想得到那个 99
【问题讨论】:
标签: python html python-3.x beautifulsoup