【发布时间】:2021-10-22 13:42:00
【问题描述】:
我在 Python 中使用 BeautifulSoup 来提取亚马逊页面上的以前的价格,但我使用的代码打印的是当前价格而不是以前的价格。
我试过了:
priceold = soup.find(class_="a-span12 a-color-secondary a-size-base").get_text()
页面是这个https://www.amazon.it/dp/B08LQ3WPWS/,我需要提取799,99€(之前的价格)。
页面上的HTML代码是:
<tr><td class="a-color-secondary a-size-base a-text-right a-nowrap">Prezzo consigliato:</td><td class="a-span12 a-color-secondary a-size-base">
<span class="a-price a-text-price a-size-base" data-a-size="b" data-a-strike="true" data-a-color="secondary"><span class="a-offscreen">799,99€</span><span aria-hidden="true">799,99€</span></span>
我只需要一个 799,99€。如何使用 BeautifulSoup 正确选择它?
我想我需要选择 a-span12 a-color-secondary a-size-base 类,同时选择 a-offscreen 类。
【问题讨论】:
标签: python html web-scraping beautifulsoup