I have this code:
url= 'https://yandex.ru/search/xml?user=uid-2h3232xfhboy&key=03.292922330523:6b4c80ghghghhghgdsfdsfds4c4b4a7872fb7d2bb04bfdgbb02b76c3d&query='
key = "абс"
url = url + key
print(url)
xml = urllib.request.urlopen(url).read()
But I got an error:
UnicodeEncodeError: 'ascii' codec can't encode characters in position 90-96: ordinal not in range(128)
What do I do?
I tried to do url= url.encode("utf-8")
But didn't help. Got this error:
AttributeError: 'bytes' object has no attribute 'timeout'
I tried to do this:
url = u''.join((self.ya_url, key)).encode('utf-8')
As suggested here: UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 20: ordinal not in range(128)
But got the same error
AttributeError: 'bytes' object has no attribute 'timeout'
What do I do?