Skip to content

Instantly share code, notes, and snippets.

@Sillium
Last active November 28, 2019 17:35
Show Gist options
  • Save Sillium/39e2754b334b2ac7a40108fc39fdc1dc to your computer and use it in GitHub Desktop.
Save Sillium/39e2754b334b2ac7a40108fc39fdc1dc to your computer and use it in GitHub Desktop.
CasperJS script to check data usage of SimplyTel mobile phone contract
// Usage: casperjs simplytel.js <login> <password>
var casper = require('casper').create({
verbose: false,
logLevel: "info",
exitOnError: true
});
if (!casper.cli.has(0) || !casper.cli.has(1)) {
casper.echo("\nUsage: casperjs simplytel.js <login> <password>").exit();
};
var login = casper.cli.get(0);
var password = casper.cli.get(1);
casper.start("https://service.simplytel.de/mytariff/invoice/showGprsDataUsage");
casper.then(function() {
this.fillSelectors('#loginAction', {
'input[id="UserLoginType_alias"]': login,
'input[id="UserLoginType_password"]': password
}, true);
});
casper.then(function() {
casper.waitForSelector('div.actualRatio',
function() {
casper.echo("Included: " + casper.getElementInfo("#currentMonth table tbody tr:nth-child(1) td:nth-child(3) b").text);
casper.echo("Available: " + casper.getElementInfo("#currentMonth table tbody tr:nth-child(3) td:nth-child(3) b").text);
casper.echo("Used: " + casper.getElementInfo("#currentMonth table tbody tr:nth-child(4) td:nth-child(3) b").text);
},
function() {
casper.echo("error");
casper.echo(login + "/" + password);
},
10000
);
});
casper.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment