Skip to content

Instantly share code, notes, and snippets.

@Dillie-O
Forked from eduardkoller/isgovtdown.py
Last active December 24, 2015 10:49
Show Gist options
  • Save Dillie-O/6786397 to your computer and use it in GitHub Desktop.
Save Dillie-O/6786397 to your computer and use it in GitHub Desktop.
Revised to work with Python 2.7
#!/usr/bin/env python
#
# file: isgovtdown.py
#
# description: checks usa.gov for the "Government has shut down" message
# Forked from https://gist.github.com/eduardkoller/6784503
# and modified to work with Python 2.7
#
# usage: ./isgovtdown.py
#
# or in a crontab:
# */5 * * * * /path/to/isgovtdown.py && mailx -s 5s [email protected]
#
import re, sys, urllib
page = urllib.urlopen("http://usa.gov").read()
if(re.search(b'Due to a lapse in funding, the U.S. federal government has shut down',page)):
print("Government still down")
sys.exit(1)
else:
print ("Government back up")
sys.exit(0)
@eduardkoller
Copy link

Nice, thanks for the fork

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment