Skip to content

Instantly share code, notes, and snippets.

@jamespeerless
Created February 9, 2014 19:02
Show Gist options
  • Save jamespeerless/8904389 to your computer and use it in GitHub Desktop.
Save jamespeerless/8904389 to your computer and use it in GitHub Desktop.
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