-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkanxue.js
38 lines (36 loc) · 1.37 KB
/
kanxue.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
import * as cheerio from "cheerio";
import got from "got";
let cookie = config.kanxue.cookie;
export default async function main() {
let result = "【看雪论坛】:"
if (!cookie) {
console.log(`${result}请填写cookie`);
return `${result}请填写cookie`;
}
let response = await got.get("https://bbs.kanxue.com/", {
headers: {
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.1938.54",
cookie: cookie
}
});
let $ = cheerio.load(response.body);
if ($("a.login_btn").text() !== "登录") {
let csrftoken = $("[name=csrf-token]").attr("content");
await got("https://bbs.kanxue.com/user-signin.htm", {
method: "POST",
body: `csrf_token=${csrftoken}`,
headers: {
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/116.0.1938.54",
cookie: cookie
}
}).then(res => {
let $ = JSON.parse(res.body);
if ($.code !== "0") result += $.message;
else result += `签到成功,获得${$.message}个雪币`;
})
} else {
result += `cookie已失效`;
}
console.log(result);
return result;
}