Advertisement
Guest User

Untitled

a guest
Dec 14th, 2018
3,030
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. !pip3 install requests
  2.  
  3. import requests
  4.  
  5. API_KEY = '7cd792d7-b811-41ba-8145-62b41fa2a6bd'
  6.  
  7. url = 'https://api.weather.yandex.ru/v1/forecast?lat=55.75396&lon=37.620393'
  8. headers = {'X-Yandex-API-Key': '7cd792d7-b811-41ba-8145-62b41fa2a6bd'}
  9.  
  10. r = requests.get(url, headers=headers)
  11.  
  12. import json
  13.  
  14. json_data = json.loads(r.text)
  15.  
  16. json_data
  17.  
  18. GEO_API = 'ec7318e6-cbb8-4ab9-b50f-0e77ff3688a6'
  19.  
  20. import urllib.parse
  21. urllib.parse.quote("Тверская+6", safe='')
  22.  
  23. r = requests.get('https://geocode-maps.yandex.ru/1.x/?apikey={API}&format=json&geocode=Тверская+6&results=5'.format(API=GEO_API))
  24.  
  25. geo_res = json.loads(r.text)
  26.  
  27. geo_res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement