rsshub
Version:
Make RSS Great Again!
111 lines (109 loc) • 3.32 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import "./ofetch-BIyrKU3Y.mjs";
import { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import { t as cache_default } from "./cache-Bo__VnGm.mjs";
import "./helpers-DxBp0Pty.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import { load } from "cheerio";
//#region lib/routes/xidian/cs.ts
const baseUrl = "https://cs.xidian.edu.cn";
const struct = {
xyxw: {
selector: { list: ".n_wenzhang ul li" },
name: "主页-学院新闻",
path: "/xyxw"
},
tzgg: {
selector: { list: ".n_wenzhang ul li" },
name: "主页-通知公告",
path: "/tzgg"
},
jlhz1: {
selector: { list: ".n_wenzhang ul li" },
name: "主页-交流合作",
path: "/jlhz1"
},
rsrc: {
selector: { list: ".n_wenzhang ul li" },
name: "主页-人事人才",
path: "rsrc"
},
bkjy_jxxw: {
selector: { list: ".n_wenzhang ul li" },
name: "主页-本科生教育 / 本科教育-教学新闻",
path: "bkjy/jxxw"
},
yjsjy_yjstz: {
selector: { list: ".n_wenzhang ul li" },
name: "主页-研究生教育 / 研究生教育-研究生通知",
path: "yjsjy/yjstz"
},
jyzhaop: {
selector: { list: ".n_wenzhang ul li" },
name: "主页-就业招聘",
path: "jyzhaop"
}
};
const route = {
path: "/cs/:category?",
categories: ["university"],
example: "/xidian/cs/xyxw",
parameters: { category: "通知类别,默认为主页-学院新闻" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
name: "计算机科学与技术学院",
url: "cs.xidian.edu.cn",
maintainers: ["ZiHao256"],
handler,
description: `| 文章来源 | 参数 |
| ---------------------- | ----------- |
| ✅主页-学院新闻 | xyxw |
| ✅主页-通知公告 | tzgg |
| ✅主页-交流合作 | jlhz1 |
| ✅主页-人事人才 | rsrc |
| ✅主页-本科生教育 / 本科教育-教学新闻 | bkjy_jxxw |
| ✅主页-研究生教育 / 研究生教育-研究生通知 | yjsjy_yjstz |
| ✅主页-就业招聘 | jyzhaop |`,
radar: [{ source: ["cs.xidian.edu.cn/"] }]
};
async function handler(ctx) {
const { category = "xyxw" } = ctx.req.param();
const url = `${baseUrl}/${struct[category].path}.htm`;
const $ = load((await got_default(url, {
headers: { referer: baseUrl },
https: { rejectUnauthorized: false }
})).data);
let items = $(struct[category].selector.list).toArray().map((item) => {
item = $(item);
return {
title: item.find("a").text(),
link: new URL(item.find("a").attr("href"), baseUrl).href,
pubDate: parseDate(item.find("span").text())
};
});
items = await Promise.all(items.map((item) => cache_default.tryGet(item.link, async () => {
const content = load((await got_default(item.link, {
headers: { referer: url },
https: { rejectUnauthorized: false }
})).data);
content(".content-sxt").remove();
item.description = content("[name=\"_newscontent_fromname\"]").html();
return item;
})));
return {
title: $("title").text(),
link: url,
item: items
};
}
//#endregion
export { route };