Issue
In my web scraping I get the price as: 524,00 kr Now I want to remove whatever is after comma. It should give me 524. Here is my code:
price = soup.find (class_ ='..............').get_text()
price = re.sub("$", "", "524,00 kr")
converted_price = float.fromhex(price2[0:4])
if(converted_price < 1000):
send_mail()
Solution
No need for a regex, use the str.split
function:
price = price.split(",")[0]
This splits the string at commas and then takes the first part.
Answered By - JustLearnedIt
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.