Last active
October 22, 2019 23:37
-
-
Save kg6zjl/93b7f648431abb5803b11f9a67a5ccf7 to your computer and use it in GitHub Desktop.
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
| # 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