我使用了BeautifulSoup,使用python从特定网站获取数据 但我不知道如何得到这些价格中的一个,但我想要以克(g)为单位的价格 如下所示,这是HTML代码:
<div class="promoPrice margBottom7">16,000
L.L./200g<br/><span class="kiloPrice">79,999
L.L./Kg</span></div>
我使用以下代码:
p_price = product.findAll("div{"class":"promoPricemargBottom7"})[0].text
我的结果是:
16,000 L.L./200g 79,999 L.L./Kg
但我想: 16000升/200克 只有
您需要首先decompose在
div
元素内的跨度:尝试使用
soup.select_one('div.promoPrice').contents[0]
印刷品
相关问题 更多 >
编程相关推荐