Last active
August 29, 2015 14:11
-
-
Save rje/4b3c62e2fed10f3395d3 to your computer and use it in GitHub Desktop.
lucario check
This file contains 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 cheerio = require('cheerio'); | |
var request = require('request'); | |
var CronJob = require('cron').CronJob; | |
var url = 'http://www.toysrus.com/product/index.jsp?productId=54369136&prodFindSrc=search&cp='; | |
function showResult(text) { | |
var proc = require('child_process'); | |
if(process.platform === 'darwin') | |
{ | |
var command = 'osascript -e \'tell app "System Events" to display dialog "' + text + '"\''; | |
proc.exec(command, function(errr, stdout, stderr) {}); | |
} | |
else | |
{ | |
proc.exec('msg "%username%" /time:99999 ' + text, function(errr, stdout, stderr) {}); | |
} | |
} | |
function parseHTML(err, resp, html) { | |
if(err) { | |
showResult(err); | |
return console.error(err); | |
} | |
var parsedHTML = cheerio.load(html); | |
var node = parsedHTML('#cartAddition'); | |
if(!node.hasClass('disabled')) { | |
showResult("GO BUY LUCARIO"); | |
} | |
} | |
function checkForItem() { | |
console.log("Performing lucario check"); | |
request(url, parseHTML); | |
} | |
function main() { | |
var job = new CronJob({ | |
cronTime: "*/15 * * * *", | |
onTick: checkForItem, | |
start: false | |
}); | |
job.start(); | |
checkForItem(); | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment