Skip to content

Instantly share code, notes, and snippets.

@MattSandy MattSandy/app.js
Created Feb 22, 2016

Embed
What would you like to do?
Food Tracker Notification for Pizza Luce
var request = require('request');
var cheerio = require('cheerio');
var notifier = require('node-notifier');
var status = "";
var url = "[tracking url]";
var interval = setInterval(function(url, notifier) {
get_status(url, notifier);
}, 30000, url, notifier);
function get_status(url) {
try {
request({method: 'GET', uri: url}, function (error, response, body) {
if (!error) {
var $ = cheerio.load(body);
if(status != $("#order-tracker-status-text").text().trim()) {
status = $("#order-tracker-status-text").text().trim();
notifier.notify({
'title': 'Pizza Status',
'message': status
});
}
if(status) {
console.log(status);
}
} else {
console.log("We’ve encountered an error: " + error);
}
});
} catch (err) {
console.log(err);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.