-
Notifications
You must be signed in to change notification settings - Fork 1
/
play-store.js
43 lines (39 loc) · 1.45 KB
/
play-store.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
var Nightmare = require('nightmare'),
vo = require('vo');
var nightmare = Nightmare({ show: false });
nightmare.goto("https://play.google.com/store/apps/developer?id="+process.argv[2])
.inject('js', 'jquery.js')
.wait("body")
.evaluate(function(){
var apps = [];
$(".card > .card-content > .card-click-target").each(function(){
apps.push("https://play.google.com"+ $(this).attr("href"));
});
return apps;
})
.then(function(apps){
console.log("Connection success. \n -------------- \n " + apps.length + " app(s) found.");
var run = function * () {
var urls = apps;
var links = [];
for (var i = 0; i < urls.length; i++) {
var title = yield nightmare.goto(urls[i])
.inject('js', 'jquery.js')
.wait('body')
.evaluate(function() {
var s = $('body .id-app-title').html() + " - (" + $("body div[itemprop='numDownloads']").html() + ")";
return s;
})
.then(function(e){
console.log(e);
})
.catch((error) => {
console.error('Connection failed.', error);
});
}
return links;
}
vo(run)(function(err) {
console.log("Process complated.");
});
})