-
Notifications
You must be signed in to change notification settings - Fork 3
/
apiweather.py
63 lines (56 loc) · 1.69 KB
/
apiweather.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#Create a free account on https://www.weatherapi.com, and add the api key to the line below
import urllib.request, json
location = "London"
apikey = ""
with urllib.request.urlopen("http://api.weatherapi.com/v1/current.json?key="+apikey+"&q="+location+"&aqi=no") as url:
data = json.load(url)
print(data['current']['condition']['code'])
print(data['current']['condition']['text'])
#1000 "Sunny"
#1003 "Partly cloudy"
#1006 "Cloudy"
#1009 "Overcast"
#1030 "Mist"
#1063 "Patchy rain possible"
#1066 "Patchy snow possible"
#1069 "Patchy sleet possible"
#1072 "Patchy freezing drizzle possible"
#1087 "Thundery outbreaks possible"
#1114 "Blowing snow"
#1117 "Blizzard"
#1135 "Fog"
#1147 "Freezing fog"
#1150 "Patchy light drizzle"
#1153 "Light drizzle"
#1168 "Freezing drizzle"
#1171 "Heavy freezing drizzle"
#1180 "Patchy light rain"
#1183 "Light rain"
#1186 "Moderate rain at times"
#1189 "Moderate rain"
#1192 "Heavy rain at times"
#1195 "Heavy rain"
#1198 "Light freezing rain"
#1201 "Moderate or heavy freezing rain"
#1204 "Light sleet"
#1207 "Moderate or heavy sleet"
#1210 "Patchy light snow"
#1213 "Light snow"
#1216 "Patchy moderate snow"
#1219 "Moderate snow"
#1222 "Patchy heavy snow"
#1225 "Heavy snow"
#1237 "Ice pellets"
#1240 "Light rain shower"
#1243 "Moderate or heavy rain shower"
#1246 "Torrential rain shower"
#1249 "Light sleet showers"
#1252 "Moderate or heavy sleet showers"
#1255 "Light snow showers"
#1258 "Moderate or heavy snow showers"
#1261 "Light showers of ice pellets"
#1264 "Moderate or heavy showers of ice pellets"
#1273 "Patchy light rain with thunder"
#1276 "Moderate or heavy rain with thunder"
#1279 "Patchy light snow with thunder"
#1282 "Moderate or heavy snow with thunder"