Created
December 21, 2015 18:25
-
-
Save d4rken/5e1ea404d6c1751271f7 to your computer and use it in GitHub Desktop.
Packagenames of all apps published by a specific developer.
This file contains 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
var request = require('request'); | |
var cheerio = require('cheerio'); | |
var rl = require("readline"); | |
var prompts = rl.createInterface(process.stdin, process.stdout); | |
// set some defaults | |
req = request.defaults({ | |
jar: true, // save cookies to jar | |
rejectUnauthorized: false, | |
followAllRedirects: true, // allow redirections | |
headers: { | |
'User-Agent': 'Mozilla/5.0 (Android 4.4; Mobile; rv:41.0) Gecko/41.0 Firefox/41.0' | |
}, | |
}); | |
prompts.question("url?", function (url) { | |
var targeturl = url; | |
console.log(targeturl); | |
prompts.question("child?", function (child) { | |
prompts.close(); | |
console.log("Loading urls..."); | |
request(targeturl, function(err, resp, body){ | |
console.log("...done!"); | |
$ = cheerio.load(body); | |
var match = $('div .card-content'); | |
$(match).each(function(i, out){ | |
var element = $(out); | |
var pkg = element.attr('data-docid'); | |
if(!pkg) | |
return true; | |
console.log("<App pkg=\"" + pkg + "\">"); | |
console.log(" " + child); | |
console.log("</App>"); | |
}); | |
}); | |
}); | |
}); |
This file contains 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
var gplay = require('google-play-scraper'); | |
var rl = require("readline"); | |
var prompts = rl.createInterface(process.stdin, process.stdout); | |
var gplay = require('google-play-scraper'); | |
prompts.question("developer id?", function (developerId) { | |
console.log(developerId); | |
prompts.question("child?", function (child) { | |
prompts.close(); | |
console.log("Loading..."); | |
gplay.developer({devId: developerId}) | |
.then(function(apps){ | |
console.log(apps.length + " apps found.") | |
apps.forEach(function(app) { | |
console.log("<App pkg=\"" + app.appId + "\">"); | |
console.log(" " + child); | |
console.log("</App>"); | |
}); | |
}) | |
.catch(function(e){ | |
console.log('There was an error fetching the application!'); | |
}); | |
}); | |
}); |
This file contains 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
var rl = require("readline"); | |
var prompts = rl.createInterface(process.stdin, process.stdout); | |
var Xray = require('x-ray'); | |
var x = Xray(); | |
function parse(url) { | |
x(url, 'div.card-content', [{ | |
pkg: '@data-docid' | |
}])(function(err, obj) { | |
console.log(obj.length + " items.") | |
console.log(obj); | |
console.log(err); | |
}).paginate('button.expand-next') | |
} | |
prompts.question("url?", function (url) { | |
var targeturl = url; | |
console.log(targeturl); | |
prompts.question("child?", function (child) { | |
prompts.close(); | |
console.log("Loading..."); | |
parse(targeturl); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment