Jake.codes

Down for Everyone, for Pythonista

Saturday, November 10, 2012

# -*- coding: utf-8 -*-
# Checks Down for Everyone
# to see if the URL in your
# clipboard is up and running
#
# By Jake Bilbrey
# http://jakebilbrey.com
import console
import clipboard
import urllib
import bs4
import webbrowser
import re

try:
    if (clipboard.get()).find("http") >= 0:
    	website = clipboard.get()
    else:
    	website = console.input_alert("Down for Everyone?","Insert a URL")

    check = bs4.BeautifulSoup(urllib.urlopen("http://www.isup.me/" + website))
    checkStr = check.find_all(text=re.compile("It's just you."))

    if checkStr:
    	console.alert("It is up!",website)
    else:
    	console.alert("It is down!",website)
except:
	console.clear()