generated from othneildrew/Best-README-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
52 lines (42 loc) · 1.37 KB
/
app.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
'use strict';
const puppeteer = require('puppeteer');
const fs = require('fs');
var os = require("os");
var path = require("path");
var apkName = "";
//console.log(process.argv.length)
if (process.argv.length >= 3) {
apkName = process.argv[2];
}
var globaltimeout = 120000;
(
async () => {
const browser = await puppeteer.launch({ headless: false})
const page = await browser.newPage()
var printerrname = './screenshot/'+apkName+".png"
var url = 'https://play.google.com/store/apps/details?id='+apkName;
console.log("requestUrl:" + url);
await page.goto(url)
.catch((err) => {
});
await page.waitFor(1500);
// await page.click('#cc-accept-btn')
// .catch((err) => {
// });
const category = await page.$eval('span.T32cc:nth-child(2) > a:nth-child(1)', el => el.innerText)
.catch((err) => {
console.log("error")
page.screenshot({path: printerrname})
});
await page.screenshot({path: printerrname})
console.log(category)
// 不覆盖,追加方式
let resultstring = apkName+","+category+os.EOL;
fs.appendFile("category.csv",resultstring,(err) => {
if (err) {
} else {
}
});
await browser.close();
}
)()