Skip to content

Instantly share code, notes, and snippets.

@MxAshUp
Last active February 24, 2016 17:35
Show Gist options
  • Save MxAshUp/9c9bd64dbe3f42200192 to your computer and use it in GitHub Desktop.
Save MxAshUp/9c9bd64dbe3f42200192 to your computer and use it in GitHub Desktop.
Checks Pi Hut Pi Zero Inventory
//Requires node-notifier for desktop notification
path = "products/raspberry-pi-zero.js"
request = require('request-json');
var client = request.createClient("http://thepihut.com/");
function check_availability() {
client.get(path, function(err, res, body) {
if(body && body.variants[4].available == true) { //I have hard-coded which product variation is associated with the Pi Zero. This should be changed if PiHut changes their Pi Zero variations.
var notifier = require('node-notifier');
notifier.notify({
title: 'PI ZERO IN STOCK',
message: 'The Pi ZERO IN STOCK!!!!',
sound: true, // Only Notification Center or Windows Toasters
});
console.log("AVAIALBE!!!!!!!!!!!!!!");
} else {
setTimeout(check_availability,1000);
}
});
}
check_availability();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment