Beautifulsoup 数据抓取从网站收集号码

阿德里安·黄

我想用 beautifulsoup 来提取数字。我的代码如下:

future=data3.find_all('span',class_='instrument-price_last__KQzyA')
    
print(future)

它将返回:

span class="instrument-price_last__KQzyA" data-test="instrument-price-last">23,989.5</span

如何从这些信息中提取 23989.5?谢谢你。

U12-转发

使用text属性:

future = float(data3.find_all('span',class_='instrument-price_last__KQzyA').text.replace(',', ''))

和:

print(future)

会给:

23989.5

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章