-
Notifications
You must be signed in to change notification settings - Fork 2
/
pupp.js
47 lines (39 loc) · 1.45 KB
/
pupp.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
const puppeteer = require("puppeteer");
const { performance } = require("perf_hooks");
const USER = {
username: "10191027",
password: ""
};
const main = async () => {
// DELETE
return console.log(">>>>>>>> 先改个账号密码再来吧");
const start = performance.now();
const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage();
await page._client.send("Network.clearBrowserCookies");
await page.setRequestInterception(true);
page.on("request", request => {
if (["image", "stylesheet", "font"].includes(request.resourceType())) {
return request.abort();
}
request.continue();
});
await page.goto(
"http://rzfw.njupt.edu.cn/cas/login?service=http%3A%2F%2F202.119.226.237%3A80%2F",
{
waitUntil: "networkidle0"
}
);
console.log(">>>>>>>>> my load", performance.now() - start);
await page.type("#username", USER.username);
await page.type("#password", USER.password);
await page.click("#dl");
await page.waitForNavigation({ waitUntil: "domcontentloaded" });
console.log(">>>>>>>>> LOGIN", performance.now() - start);
await page.goto("http://yjs.njupt.edu.cn/epstar/web/swms/mainframe/home.jsp");
console.log(">>>>>>>>> YJS", performance.now() - start);
const cookies = await page.cookies();
cookies.map(({ name, value }) => console.log(`>>>>>>> ${name} = ${value}`));
console.log(">>>>>>>>>>>>> FIN", performance.now() - start, "\n\n\n");
};
main();