forked from hawa130/health-card-checkin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
yqt-check.js
44 lines (39 loc) · 1.09 KB
/
yqt-check.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
const puppeteer = require('puppeteer');
const argv = process.argv;
let username;
let password;
let geoData;
if (argv.length < 3) {
username = '你的学号';
password = '你的密码';
geoData = {
"type": "complete",
// ...
"info": "SUCCESS"
};
} else {
username = argv[2];
password = argv[3];
geoData = JSON.parse(argv[4]);
}
const url = 'https://xxcapp.xidian.edu.cn/ncov/wap/default/index';
const saveUrl = 'https://xxcapp.xidian.edu.cn/ncov/wap/default/save';
const handle = () =>
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(url);
await page.evaluate((username, password) => {
vm.username = username;
vm.password = password;
vm.login();
}, username, password);
await page.waitForNavigation({ waitUntil: "domcontentloaded" });
await page.evaluate((geoData) => vm.locatComplete(geoData), geoData);
await page.evaluate(() => vm.save());
const res = await page.waitForResponse(saveUrl);
const log = await res.json();
console.log(log['m']);
await browser.close();
})();
handle();