Skip to content

Instantly share code, notes, and snippets.

@sud0n1m
Last active June 22, 2016 05:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sud0n1m/3fd8cf439ca67350d2f4d19ca378ebd3 to your computer and use it in GitHub Desktop.
Save sud0n1m/3fd8cf439ca67350d2f4d19ca378ebd3 to your computer and use it in GitHub Desktop.
// 1. Add this file to a tests directory and name it netflix.js.
// 2. Create a docker container that mounts that directory
// docker run -it -d --name casper2 -v /mnt/user/tests:/tests rdpanek/casperjs bin/bash
// 3. Set up an hourly cron job by creating a new file
// #!/bin/bash
// docker exec casper2 casperjs /tests/netflix.js
// Then add a command to /etc/cron.hourly/speedtest to run this script in the container and chmod +x that file.
var casper = require('casper').create();
casper.options.waitTimeout = 120000;
var speed = 1;
var units;
casper.start('https://fast.com/', function() {
this.echo(this.getTitle());
});
casper.waitForSelector('.succeeded', function() {
speed = this.getHTML('div#speed-value');
units = this.getHTML('div#speed-units');
this.echo(speed + " " + units);
casper.thenOpen('https://maker.ifttt.com/trigger/USEYOUROWNKEY!', {
method: 'post',
data: {
'value1': speed,
'value2': units,
'value3': "home"
}
});
});
casper.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment