Created
February 9, 2014 19:02
-
-
Save jamespeerless/8904389 to your computer and use it in GitHub Desktop.
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
var jsdom = require("jsdom"); | |
var request = require('request'); | |
var sys = require('sys'); | |
var exec = require('child_process').exec; | |
getPage = function(someUri, callback) { | |
request({uri: someUri, headers:{'User-Agent': 'Mozilla/5.0'}}, function (error, response, body) { | |
callback(body); | |
}); | |
} | |
var loading = false; | |
checkGox = function(){ | |
loading = true; | |
getPage('http://www.mtgox.com/news', function(body) { | |
jsdom.env(body,["http://code.jquery.com/jquery.js"], function (errors, window) { | |
var $ = window.$; | |
var headline = $(".newsFeed li a").first().attr("href"); | |
if(headline != "https://www.mtgox.com/press_release_20140207.html"){ | |
console.log("OMG NEWS"); | |
exec("say 'OMG GO CHECK'"); | |
} else { | |
console.log((new Date()).getTime() + ": no news yet..."); | |
loading = false; | |
} | |
}); | |
}); | |
} | |
setInterval(function(){ | |
if(!loading){ | |
checkGox() | |
} | |
}, 8000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment