You seem to have commas (,
) in some of your prices.
Try this:
import locale
# Set to US locale
locale.setlocale(locale.LC_ALL, 'USA')
prices = soup.find_all("span", itemprop="price")
for i in prices:
price_in_dec = Decimal(locale.atof(i.text))
if price_in_dec <= price_thres:
print(price_in_dec)
By using the correct locale, you can parse the prices according to the way you write them in the US.
Another option would be to simply remove commas using i.text.replace(",", "")
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…