Last active
June 8, 2021 07:33
-
-
Save diodon/54f8e1fa15925ff7190ee7d74ce02d46 to your computer and use it in GitHub Desktop.
Get the online status of AIMS weather stations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| import requests | |
| import prettytable | |
| ## get the latest data using AIMS WS wer service | |
| AIMSurl = "https://api.aims.gov.au/weather/latestreadings" | |
| WSjson = json.loads(requests.get(AIMSurl).text) | |
| ## print the online status of each of the stations | |
| tbl = prettytable.PrettyTable(["ID", "STATION", "STATUS"]) | |
| for item in range(len(WSjson)): | |
| if WSjson[item]['status']['online'] == 'true': | |
| status = 'ONLINE' | |
| else: | |
| status = 'OFFLINE' | |
| tbl.add_row([WSjson[item]['site_id'], WSjson[item]['site_name'], status]) | |
| print(tbl) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment