如何使用 BS4 和 Python 从 div 中抓取一个跨度

How to scrape a span from a div using BS4 and Python

我正在尝试从网站上抓取这些代码行,我的重点是跨度之间的内容,不幸的是我没能抓取到它,我不断收到奇怪的错误。

<div class="u-font-weight-bold u-font-size-l be-lot-current-bid__amount-label"><span class="u-no-wrap u-margin-r-small">Offerta attuale 222 € </span></div>

你们知道如何获得“Offerta attuale 222 €”吗?

有了完整的 html 和您的脚本,可能会更容易帮助您。

试试这个,然后告诉我它是否适合你。

offerta = soup.find(class_ = 'u-no-wrap u-margin-r-small').get_text()