new_text = text.decode('utf-8').replace('\u00a0', ' ').replace('\u00ad', ' ').replace('Â', ' ').replace(' ',' ').replace(' ', ' ').replace(' ', ' ').replace('\u20b9',' ').replace('\ufffd',' ').replace('\u037e',' ').replace('\u2022',' ').replace('\u200b',' ').replace('0xc3',' ') This is the error produced by the code:
new_text = text.decode('utf-8').replace('\u00a0', ' ').replace('\u00ad', ' ').replace('Â', ' ').replace(' ', UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128) 127.0.0.1 - - [29/Aug/2017 15:22:00] "GET / HTTP/1.1" 500 - I have tried decoding ascii from unicode.
text?.replace('Â', ' ')and you need to use Unicode strings everywhere (u'\u00a0', etc.).