Skip to content

Instantly share code, notes, and snippets.

@kg6zjl
Last active October 22, 2019 23:37
Show Gist options
  • Select an option

  • Save kg6zjl/93b7f648431abb5803b11f9a67a5ccf7 to your computer and use it in GitHub Desktop.

Select an option

Save kg6zjl/93b7f648431abb5803b11f9a67a5ccf7 to your computer and use it in GitHub Desktop.
# encoding=utf8
from __future__ import print_function
import requests
from bs4 import BeautifulSoup
url = "https://status.aws.amazon.com/"
allGreen = True
r = requests.get(url)
c = r.content
if r.status_code != 200:
print("something failed, status code: " + str(r.status_code))
exit()
soup = BeautifulSoup(c, "html.parser")
current_events = soup.find("div", {"id": "current_events_block"}) #only look at current events table
tables = current_events.findChildren('table')
for table in tables:
rows = table.findChildren(['th', 'tr'])
for row in rows:
problem = False
columns = row.findChildren('td')
for columns in columns:
images = columns.findChildren('img')
for image in images:
if "status" in image['src']:
if "status0" not in image['src']:
problem = True
allGreen = False
if problem:
try:
print("Not green: "+str(row.findChildren('td')[1].contents))
print("========================================================")
except:
print(str(row))
if allGreen:
print("All services green.")
exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment