Advertisement
niromru

WEB Знакомство с API ---> Исторический музей

Mar 10th, 2021
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. import requests
  2.  
  3. geocoder_request = "http://geocode-maps.yandex.ru/1.x/?apikey=40d1649f-0493-4b70-98ba-98533de7710b&geocode='Красная пл-дь, 1'&format=json"
  4.  
  5. response = requests.get(geocoder_request)
  6. if response:
  7.     json_response = response.json()
  8.     toponym = json_response["response"]["GeoObjectCollection"]["featureMember"][0]["GeoObject"]
  9.     toponym_address = toponym["metaDataProperty"]["GeocoderMetaData"]["text"]
  10.     toponym_coodrinates = toponym["Point"]["pos"]
  11.     print(toponym_address, "имеет координаты:", toponym_coodrinates)
  12. else:
  13.     print("Ошибка выполнения запроса:")
  14.     print(geocoder_request)
  15.     print("Http статус:", response.status_code, "(", response.reason, ")")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement