Created
August 2, 2014 01:30
-
-
Save tfaris/1c850bed3ff25df05d03 to your computer and use it in GitHub Desktop.
This file contains 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 requests | |
import time | |
from pyquery import PyQuery | |
SLEEP_TIME = 60 * 5 | |
SERVICES = ( | |
'SocialandGaming', | |
'XboxLiveCoreServices', | |
'PurchaseandContentUsage', | |
'Website', | |
'TVMusicandVideo', | |
) | |
class XboxLiveStatus(object): | |
def __init__(self): | |
r = requests.get('http://support.xbox.com/en-US/xbox-live-status') | |
self.pq = PyQuery(r.content) | |
def check_service(self, service_name): | |
if self.pq('#%s.unavailable' % service_name): | |
return 'limited' | |
elif self.pq('#%s.active' % service_name): | |
return 'online' | |
else: | |
return 'unavailable' | |
while True: | |
xbls = XboxLiveStatus() | |
for svc_name in SERVICES: | |
status = xbls.check_service(svc_name) | |
print('%s : %s' % (svc_name, status)) | |
print('') | |
time.sleep(SLEEP_TIME) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment