0

I am using BeautifulSoup to scrape data. The text I want to scrape is "€ 48,50", which contains an ascii character. However, I would like to replace the euro sign with nothing so that the final output is "48,50". I have been getting errors because the console cannot print it. I am using python 2.7 on Windows for this. I will appreciate a solution.

I was basically getting errors and do not know how to go about this. Or is there a way I can just extract non-ascii characters alone?

w= item.find_all("div",{"class":"product-price"}).find("strong", {"class":"product-price__money"}).text.replace("\\u20ac"," ") print w 

1 Answer 1

1

You need to decode the string and pass the replace function a unicode string.

text = "€ 48,50" w = text.decode("utf-8").replace(u"\u20ac"," ") print w 

See How to replace unicode characters in string with something else python? for more details.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, this is the solution I ended up using at the time. I needed to decode the character

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.