Skip to content

Instantly share code, notes, and snippets.

@lilmuckers
Created June 26, 2013 21:04
Show Gist options
  • Save lilmuckers/5871663 to your computer and use it in GitHub Desktop.
Save lilmuckers/5871663 to your computer and use it in GitHub Desktop.
CasperJS script to pull Xbox LIve data
//spawn the casper process
var casper = require("casper").create();
var sourceString = '';
//get the URL
if(casper.cli.has(0)){
var url = casper.cli.get(0)
} else {
casper
.echo("Usage: $ casperjs casperjs.js <url>")
.exit(1)
;
}
var user, pass = null;
//get the login arguments
if(casper.cli.has(1)){
user = casper.cli.get(1);
pass = casper.cli.get(2);
}
casper.start(url, function() {
sourceString = this.evaluate(function(username, password){
//login
if(document.querySelectorAll('input#i0116').length > 0){
document.getElementById('i0116').value = username;
document.getElementById('i0118').value = password;
document.getElementById('idSIButton9').click();
return true;
} else if(!document.getElementById("ProductTitleZone") && window.location.href.indexOf('marketplace.xbox.com') >= 0) {
var links = document.getElementsByTagName('a');
for(var k in links){
if(!links[k].href){
continue;
}
if(links[k].href.indexOf("nosplash") >= 0){
window.location = links[k].href;
break;
}
}
return true;
} else {
return false;
}
},{
username: user,
password: pass
});
});
casper.then(function(){
this.debugHTML();
});
casper.run(function(){
this.exit();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment