-
Notifications
You must be signed in to change notification settings - Fork 0
/
index-ps.js
82 lines (75 loc) · 2.4 KB
/
index-ps.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
var gplay = require("google-play-scraper");
const parseDomain = require("parse-domain");
var HunterSDK = require("hunterio");
require("dotenv").config();
// Hunter.io setup
var KEY = process.env.HUNTER_API_KEY;
var hunter = new HunterSDK(KEY);
// Writer CSV
const createCsvWriter = require("csv-writer").createObjectCsvWriter;
const csvWriter = createCsvWriter({
path: "doc/playstore/[FR][TRENDING][SPORTS]play-store-scrapper.csv",
header: [
{ id: "appName", title: "App Name" },
{ id: "publisherName", title: "Publisher Name" },
{ id: "publisherDomain", title: "Publisher Domain" },
{ id: "realDomain", title: "Real Domain" },
{ id: "categorie", title: "Categorie" },
{ id: "installation", title: "Installations" },
{ id: "ratingScore", title: "Rating Score" },
{ id: "ratingNumber", title: "Rating Number" },
{ id: "developerEmail", title: "Developer Email" },
],
});
// Get the list of the apps, sort by categories and collection
var data = [];
var emails = [];
gplay
.list({
category: gplay.category.SPORTS,
collection: gplay.collection.TRENDING,
num: 500,
country: "fr",
fullDetail: true,
lang: "fr",
price: "free",
})
.then(function (apps) {
apps.forEach((app) => {
// Get the domain from the developer website to give to hunter.io
if (app.developerWebsite) {
parsedDomain = parseDomain(app.developerWebsite);
realDomainFromPublisherDomain =
parsedDomain.domain + "." + parsedDomain.tld;
// Hunter.io call API to get the email
hunter.domainSearch(
{
domain: realDomainFromPublisherDomain,
},
function (err, body) {
if (err) {
// handle error
} else {
// Will contain same body as the raw API call
console.log(body.data.emails);
}
}
);
} else {
realDomainFromPublisherDomain = "";
}
data.push({
appName: app.title,
publisherName: app.developer,
publisherDomain: app.developerWebsite,
realDomain: realDomainFromPublisherDomain,
categorie: app.genre,
installation: app.minInstalls,
ratingScore: app.score,
ratingNumber: app.ratings,
developerEmail: emails,
});
csvWriter.writeRecords(data);
});
})
.catch((err) => console.log("An error occurred", err));