Skip to content

Instantly share code, notes, and snippets.

@programmingthomas
Created July 29, 2013 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save programmingthomas/6102701 to your computer and use it in GitHub Desktop.
Save programmingthomas/6102701 to your computer and use it in GitHub Desktop.
ADC Developer Status Python script - Python 2.7 - Prints a list of all of the Apple Developer services that are currently online
import urllib2
from HTMLParser import HTMLParser
class MyHTMLParser(HTMLParser):
entered_status_table = False
in_table_cell_tag = False
status_online = False
services_online = {}
def get_class(self, attrs):
v = ""
for attr in attrs:
if attr[0] == 'class':
return attr[1]
return v
def handle_starttag(self, tag, attrs):
if tag == 'table' and self.get_class(attrs) == 'status-table':
self.entered_status_table = True
if self.entered_status_table and tag == 'td':
self.in_table_cell_tag = True
self.status_online = self.get_class(attrs) == 'online'
def handle_endtag(self, tag):
if tag == 'table':
self.entered_status_table = False
elif tag == 'td':
self.in_table_cell_tag = False
def handle_data(self, data):
if self.in_table_cell_tag and self.entered_status_table:
self.services_online[data] = self.status_online
response = urllib2.urlopen("https://developer.apple.com/support/system-status/")
data = response.read()
#The & sign was messing up the Python parser in 'Certificates, Identifiers & Profiles'
data = data.replace("&", "and")
#Create the HTML parser
parser = MyHTMLParser()
parser.feed(data)
for service in parser.services_online:
if parser.services_online[service]:
print service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment