Федотов Asked:2022-02-16 16:43:48 +0800 CST2022-02-16 16:43:48 +0800 CST 2022-02-16 16:43:48 +0800 CST Python BeautifulSoup 获得价格 [关闭] 772 <span class="price"><span>Цена:</span> 58 436 <span class="currency">руб.</span></span> 如何仅获得 58436 ? python 1 个回答 Voted Best Answer Jack_oS 2022-02-16T16:56:00+08:002022-02-16T16:56:00+08:00 html = '<span class="price"><span>Цена:</span> 58 436 <span class="currency">руб.</span></span>' from bs4 import BeautifulSoup soup = BeautifulSoup(html, 'html.parser') span = soup.find_all('span') cost = span.text.replace('Цена: ', '').replace('\xa0', '').replace(' руб.', '') >>> cost 58436
1 个回答