I'm trying to extract prices from a website.
The code I've written can do that, but when the website has a price that also shows the old price, it returns "none" instead of a string of the price.
This is an example of the code without the old price (which my code returns as a string)
<div class="xl-price rangePrice">
535.000 €
</div>
This is an example of the code WITH the old price (which my code returns as "none")
< div
class ="xl-price rangePrice" >
487.000 €
< span
class ="old-price" > 497.000 € < br > < / span >
< / div >
The page I'm trying to extract code from: pagelink
My code:
prices = []
for items in soup.find_all("div", {"class": "xl-price rangePrice"}):
prices.append(items.string)
print(prices)
and another issue I'm having is that it returns the values like this:
'\r\n\t\t\t\t\t\t\t\t298.000 € \r\n\t\t\t\t\t\t\t', '\r\n\t\t\t\t\t\t\t\t145.000 € \r\n\t\t\t\t\t\t\t'
when I only want the numbers.
Would appreciate the help!