Answer the question
In order to leave comments, you need to log in
How to add Russian character encoding to the requests library request (Python and Geocoder API from Yandex)?
There is an API Geocoder from Yandex, in which there is a receipt of address coordinates by reference. Request example: . It contains Russian letters and requests does not get along with them. My request function:
def requestsGet():
r = requests.get('https://https://geocode-maps.yandex.ru/1.x/?apikey=7cf0c3a3-4ae5-4e20-8250-34d99c8eb365=Москва,+Тверская+улица,+дом+7', params={'format': 'json'})
print('Url запроса:', r.url)
return r.json()
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='https', port=443): Max retries exceeded with url: //geocode-maps.yandex.ru/1.x/?apikey=7cf0c3a3-4ae5-4e20-8250- 34d99c8eb365=%D0%9C%D0%BE%D1%81%D0%BA%D0%B2%D0%B0,+%D0%A2%D0%B2%D0%B5%D1%80%D1%81%D0 %BA%D0%B0%D1%8F+%D1%83%D0%BB%D0%B8%D1%86%D0%B0,+%D0%B4%D0%BE%D0%BC+7&format=json (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))
Answer the question
In order to leave comments, you need to log in
The resulting result
%D0%9C%D0%BE%D1%81%D0%BA%D0%B2%D0%B0,+%D0%A2%D0%B2%D0%B5%D1%80%D1%81%D0%BA%D0%B0%D1
and there is an encoding. This is absolutely valid syntax. And requests, surprisingly, throws an error:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question