Skip to content

Instantly share code, notes, and snippets.

@diodon
Last active June 8, 2021 07:33
Show Gist options
  • Select an option

  • Save diodon/54f8e1fa15925ff7190ee7d74ce02d46 to your computer and use it in GitHub Desktop.

Select an option

Save diodon/54f8e1fa15925ff7190ee7d74ce02d46 to your computer and use it in GitHub Desktop.
Get the online status of AIMS weather stations
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