Created
February 12, 2013 18:19
-
-
Save edmore/4772007 to your computer and use it in GitHub Desktop.
Check if site is down from (using headless webkit)
This file contains hidden or 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
#! /usr/bin/env ruby | |
########################################################## | |
# Description - Check whether site is up or down via the | |
# command line. | |
# Author - www.edmoremoyo.com | |
# Dependency - phantomjs ( http://phantomjs.org/ ) | |
########################################################## | |
url = ARGV[0] | |
js_file = File.new("updown.js", "w+") | |
js = <<HERE | |
var page = require('webpage').create(); | |
page.open('http://www.isup.me/#{url}', function () { | |
var response = page.evaluate(function () { | |
return document.getElementById("container").innerHTML; | |
}); | |
var upOrDown = /looks down from here/.exec(response); | |
(upOrDown !== null) ? console.log("#{url} is DOWN dude! Ain't just you.") : console.log("#{url} is UP! Jus you."); | |
phantom.exit(); | |
}); | |
HERE | |
js_file.puts js | |
js_file.close | |
system("phantomjs updown.js") | |
system("rm -f updown.js > /dev/null") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment