Skip to content

Instantly share code, notes, and snippets.

@dheaney
Last active December 14, 2015 06:48
Show Gist options
  • Save dheaney/5045139 to your computer and use it in GitHub Desktop.
Save dheaney/5045139 to your computer and use it in GitHub Desktop.
Air1.js
#!/usr/bin/env phantomjs
// Copyright (C) 2013 - dejay
//
// Air1.js is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Air1.js is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Air1.js. If not, see <http://www.gnu.org/licenses/>.
var page = require('webpage').create();
var code;
page.open('http://www.air1.com/music/free-songs.aspx', function (status) {
if (status !== 'success') {
console.log('error');
phantom.exit();
return;
}
page.evaluate(function() {
__doPostBack('ctl00$cphRight1$itunesPromo$lbGetDownloadCode','');
});
setTimeout(function() {
code = page.evaluate(function() {
return document.getElementById('ctl00_cphRight1_itunesPromo_lblItunesCodes').innerText;
});
}, 1000);
});
var server = require('webserver').create();
server.listen(8080, function(request, response) {
response.statusCode = 200;
response.write("{ \"air1\": \"" + code + "\" }" + "\n");
response.close();
});
//===NOTES===//
//
//'itmss://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/freeProductCodeWizard?code=' + code
//
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment