forked from Logan1x/Python-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathair-quality.py
More file actions
21 lines (18 loc) · 845 Bytes
/
Copy pathair-quality.py
File metadata and controls
21 lines (18 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
"""Script to get the air quality based on the user's current location"""
import sys
import requests as req
if __name__ == "__main__":
if len(sys.argv) > 1:
url = "https://api.waqi.info/feed/here/?token=" + sys.argv[1]
response = req.get(url, verify=False)
if response.json()['status'] == "ok":
print("The air quality is " + str(response.json()['data']['aqi']))
print("The data was fetched from " +
response.json()['data']['city']['name'])
print("The pollutant measured was " +
str(response.json()['data']['dominentpol']))
elif response.json()['status'] == "error":
print("The server returned an error. The message is " +
response.json()['data'])
else:
print("Cannot fetch AQI without token")