|
12345678910111213141516171819202122232425262728293031323334 |
- import requests #pip install requests
- from config import Weather
- import json #pip install json
-
-
-
- def get_data():
- url = "https://api.openweathermap.org/data/2.5/onecall?lat=%s&lon=%s&appid=%s&units=metric" % (Weather['lat'], Weather['lon'], Weather['API_key'])
- response = requests.get(url)
- # print(url)
- data = json.loads(response.text)
- return data
-
-
- def weather_tomorrow():
- data = get_data()
- weather = data['daily'][1]['weather'][0]['main']
- return weather
-
- def weather_today():
- data = get_data()
- weather = data['daily'][0]['weather'][0]['main']
- return weather
-
-
- def get_temp_today():
- data = get_data()
- temp = data['daily'][0]['temp']['day']
- return temp
-
- def get_temp_tomorrow():
- data = get_data()
- temp = data['daily'][1]['temp']['day']
- return temp
|