首页 > 解决方案 > 如何使用beautifulsoup从div下面提取id数据值?

问题描述

请帮我。我已经尝试了很多事情,但我无法做到这一点。

<div class="dfx-singleInstrument__price dfx-rate dfx-font-size-3 font-weight-bold text-right" data-stream-type="price" data-symbol="EURUSD" data-market-id="EURUSD" data-type="bid" data-change-scale="-1" data-unscaling-factor="10000" data-unscaled-decimals="5" data-value="1.18610">
</div>

标签: pythonweb-scrapingbeautifulsoupscrapy

解决方案


采用:

soup.select_one('.singleInstrument__price')['data-value']

推荐阅读