Last active
June 22, 2016 05:58
-
-
Save sud0n1m/3fd8cf439ca67350d2f4d19ca378ebd3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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