I have the following code that outputs data extracted from <div>
tag.
s = BeautifulSoup(driver.page_source, "lxml")
best_price_tags = s.findAll('div', "flt-subhead1 gws-flights-results__price gws-flights-results__cheapest-price")
best_prices = []
for tag in best_price_tags:
best_prices.append(tag.text.replace('€', '').strip())
The first element of the variable best_price_tags
contains the following:
<div class="flt-subhead1 gws-flights-results__price gws-flights-results__cheapest-price"> 1 820 € </div>
I am expecting from the above code to output only the value 1821.
The above code chunk has a problem where it outputs the following, consider the case of best_price_tags[0]
, '1\u202f821'
.
I tried the following but unfortunately did not work for me.
for tag in best_price_tags:
best_prices.append(int(tag.text.replace('€', '').strip()))
Looking for an automated solution without using NLP modules.
NOTE: I have edited the exact value <div>
tag has. It was <div class='...'>1 820 €</div>
and now it is <div class='...'> 1 820 € </div>
.