Allow https, too

Also a bit easier to extend down detection to more sophisticated methods.
This commit is contained in:
KaneTW 2014-12-01 23:11:07 +01:00
parent d1a9309b03
commit 26c199d1cc
1 changed files with 8 additions and 6 deletions

View File

@ -5,13 +5,15 @@ from util import hook, http
@hook.command
def down(inp):
'''.down <url> -- checks to see if the site is down'''
if 'http://' not in inp:
inp = 'http://' + inp
inp = 'http://' + urlparse.urlparse(inp).netloc
'''.down <url> -- checks to see if the website is down'''
urlp = urlparse.urlparse(inp, 'http')
if urlp.scheme not in ('http', 'https'):
return inp + " is not a valid HTTP URL"
inp = "%s://%s" % (urlp.scheme, urlp.netloc)
# http://mail.python.org/pipermail/python-list/2006-December/589854.html
try:
http.get(inp, get_method='HEAD')