Skip to content

Instantly share code, notes, and snippets.

@Ivanca
Last active November 3, 2015 01:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ivanca/aef2e58dbbf9eb3e1bd4 to your computer and use it in GitHub Desktop.
Save Ivanca/aef2e58dbbf9eb3e1bd4 to your computer and use it in GitHub Desktop.
You would have to use this with a cronjob or something of the sort
var casper = require('casper').create({viewportSize: {width: 960, height: 600}});
var fs = require('fs');
casper.start('https://news.ycombinator.com/', function() {
var now = this.fetchText('#hnmain');
var old = fs.read('old.txt');
if (old !== now) {
casper.open('http://text-compare.com/', {
method: 'post',
data: {'text1': old, 'text2': now}
}).then(function () {
casper.captureSelector('diff' + Date.now() + '.png', '#top');
// Code to notify you here, e.g. IFTTT API, mail, etc
});
fs.write('old.txt', now, 'w');
}
}).run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment