-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
70 lines (64 loc) · 2.68 KB
/
index.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
const _ = require('lodash');
const axios = require('axios');
const jsdom = require('jsdom');
const xlsx = require('xlsx');
const fs = require('fs');
const { log } = console;
const { JSDOM } = jsdom;
const ax = axios.create({
// Option 1
baseURL: 'http://q1.jletv.cn/',
// Option 2
// baseURL: 'http://q2.jletv.cn/',
// Option 3
// baseURL: 'http://q3.jletv.cn/',
timeout: 2000,
});
const query = async (ksh, xm) => {
const { data } = await ax.get('wechat/gk-inquery.php', {
params: {
ksh,
xm,
message: '',
},
});
const dom = new JSDOM(data);
const ywCell = dom.window.document.querySelector('body > div > div.main.main-search.main-gk > div > div > div > table > tbody > tr:nth-child(1) > td:nth-child(2)');
const sxCell = dom.window.document.querySelector('body > div > div.main.main-search.main-gk > div > div > div > table > tbody > tr:nth-child(2) > td:nth-child(2)');
const zhCell = dom.window.document.querySelector('body > div > div.main.main-search.main-gk > div > div > div > table > tbody > tr:nth-child(3) > td:nth-child(2)');
const wyCell = dom.window.document.querySelector('body > div > div.main.main-search.main-gk > div > div > div > table > tbody > tr:nth-child(4) > td:nth-child(2)');
const mzCell = dom.window.document.querySelector('body > div > div.main.main-search.main-gk > div > div > div > table > tbody > tr:nth-child(5) > td:nth-child(2)');
const zfCell = dom.window.document.querySelector('body > div > div.main.main-search.main-gk > div > div > div > table > tbody > tr:nth-child(6) > td:nth-child(2)');
if (zfCell) {
return {
zf: parseInt(zfCell.textContent, 10),
yw: parseInt(ywCell.textContent, 10),
sx: parseInt(sxCell.textContent, 10),
wy: parseInt(wyCell.textContent, 10),
zh: parseInt(zhCell.textContent, 10),
mz: parseInt(mzCell.textContent, 10),
};
}
return {
zf: 0,
};
};
const invoke = (data, i, maxL) => {
const csh = data[i]['考生号'].trim();
const xm = data[i]['姓名'].trim();
query(csh, xm).then((cj) => {
log(`${data[i]['姓名']}, ${cj.zf}, ${i + 1}/${maxL}`);
fs.appendFileSync('./data/res.txt', `${csh},${xm},${cj.yw},${cj.sx},${cj.zh},${cj.wy},${cj.mz},${cj.zf}\n`);
if (i < maxL - 1) _.delay(invoke, 300, data, i + 1, maxL);
}).catch((error) => {
console.error(error.code);
if (i < maxL - 1) _.delay(invoke, 300, data, i, maxL);
});
};
const workbook = xlsx.readFile('data/2021.xlsx');
const snl = workbook.SheetNames;
const xlData = xlsx.utils.sheet_to_json(workbook.Sheets[snl[0]]);
// invoke(xlData, 0, 2);
invoke(xlData, 0, xlData.length);
// console.log(dt['考生号'].trim(), dt['姓名'].trim());
// query(17220104153346, '王天贺');