I have a list of songs I am trying to use to search with through YouTube. However, when certain songs with special characters are used, the following error pops up:
Code:
import urllib.request
import re
search_kw = tracks[3]['Artist'] + '+' + tracks[3]['Track Title']
search_kw = search_kw.replace(' ','+')
html = urllib.request.urlopen("https://www.youtube.com/results?search_query=" + search_kw)
video_ids = re.findall(r"watch\?v=(\S{11})", html.read().decode())
print("https://www.youtube.com/watch?v=" + video_ids[0])
UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' in position 43: ordinal not in range(128)
Example of string that causes error:
Tutu Au Mic' – dumbéa
How can I convert the special characters into regular characters to prevent the error from occurring?