Skip to content

Instantly share code, notes, and snippets.

@Ivanca

Ivanca/scrapehn.js

Last active Nov 3, 2015
Embed
What would you like to do?
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
You can’t perform that action at this time.