From 906f95e2e871b0a3d403fbdf412c90bd9cf58297 Mon Sep 17 00:00:00 2001 From: LMark <40017222+ladeng07@users.noreply.github.com> Date: Wed, 20 Mar 2024 00:32:41 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20=20=E4=B8=AD=E5=9B=BD=E6=B5=B7?= =?UTF-8?q?=E6=B4=8B=E5=A4=A7=E5=AD=A6=E5=90=8E=E5=8B=A4=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=20(#14854)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add 中国海洋大学后勤通知 * Update lib/routes/ouc/hqsz.ts * Update lib/routes/ouc/hqsz.ts --------- --- lib/routes/ouc/hqsz.ts | 89 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 lib/routes/ouc/hqsz.ts diff --git a/lib/routes/ouc/hqsz.ts b/lib/routes/ouc/hqsz.ts new file mode 100644 index 0000000000..33dd96832f --- /dev/null +++ b/lib/routes/ouc/hqsz.ts @@ -0,0 +1,89 @@ +import { parseDate } from '@/utils/parse-date'; +import got from '@/utils/got'; +import cache from '@/utils/cache'; +import CryptoJS from 'crypto-js/crypto-js'; + +export const route: Route = { + path: '/hqsz', + categories: ['university'], + example: '/ouc/hqsz', + parameters: {}, + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: true, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + radar: [ + { + source: ['hqsz.ouc.edu.cn/news.html'], + }, + ], + name: '后勤公告通知', + maintainers: ['ladeng07'], + handler, + url: 'hqsz.ouc.edu.cn/news.html?typeId=02', +}; + +function Decrypt(word, keyStr = '1974051005060708', ivStr = '1974051005060708') { + const key = CryptoJS.enc.Utf8.parse(keyStr); // ""中与后台一样 密码 + const iv = CryptoJS.enc.Utf8.parse(ivStr); // ""中与后台一样 + const base64 = CryptoJS.enc.Base64.parse(word); + const src = CryptoJS.enc.Base64.stringify(base64); + + const decrypt = CryptoJS.AES.decrypt(src, key, { + iv, + mode: CryptoJS.mode.CBC, + padding: CryptoJS.pad.Pkcs7, + }); + + const decryptedStr = decrypt.toString(CryptoJS.enc.Utf8); + return decryptedStr; +} + +async function handler() { + const base = 'http://hqsz.ouc.edu.cn/'; + const link = base + 'api/website/frontendWebsite/lists'; + const { data } = await got.post(link, { + form: { + schoolCode: '10423', + website: '89e97da117d547128283cf9d12891fa9', + code: '0202', + pageSize: '10', + pageIndex: '1', + }, + }); + const list = JSON.parse(Decrypt(data)).data.list.map((item) => ({ + title: item.title, + id: item.id, + author: item.author, + link: base + 'news_detail.html?id=' + item.id, + pubDate: parseDate(item.publishTime), + })); + + const out = await Promise.all( + list.map((item) => + cache.tryGet(item.link, async () => { + const { data } = await got.post(base + 'api/website/frontendWebsite/info', { + form: { + schoolCode: '10423', + website: '89e97da117d547128283cf9d12891fa9', + id: item.id, + }, + }); + item.description = Decrypt(JSON.parse(Decrypt(data)).data.content); + delete item.id; + return item; + }) + ) + ); + + return { + title: '中国海洋大学后勤公告通知', + link, + description: '中国海洋大学后勤公告通知', + item: out, + }; +}