-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.py
More file actions
30 lines (22 loc) · 806 Bytes
/
parser.py
File metadata and controls
30 lines (22 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import requests
from datetime import datetime
s_city = "Moscow,RU"
city_id = 524901
appid = "36864f4aec2acf7d8abf1d0afa33df75"
def getWeather():
try:
res = requests.get("http://api.openweathermap.org/data/2.5/weather",
params={'id': city_id, 'units': 'metric', 'lang': 'ru', 'APPID': appid})
data = res.json()
print(data)
temp = data['main']['temp']
feelsLike = data['main']['feels_like']
windSpeed = data['wind']['speed']
conditions = data['weather'][0]['description']
except Exception as e:
print("Exception (weather):", e)
pass
return (temp, feelsLike, windSpeed, conditions)
def getTime():
time = datetime.now().strftime('%H:%M:%S')
return time