rsshub
Version:
Make RSS Great Again!
83 lines (81 loc) • 2.63 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 { t as timezone } from "./timezone-D8cuwzTY.mjs";
import { load } from "cheerio";
//#region lib/routes/sdu/mech.ts
const typelist = [
"通知公告",
"院所新闻",
"教学信息",
"学术动态",
"学院简报"
];
const urlList = [
"xwdt/tzgg.htm",
"xwdt/ysxw.htm",
"xwdt/jxxx.htm",
"xwdt/xsdt.htm",
"xwdt/xyjb.htm"
];
const host = "https://www.mech.sdu.edu.cn/";
const route = {
path: "/mech/:type?",
categories: ["university"],
example: "/sdu/mech/0",
parameters: { type: "默认为 `0`" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
name: "机械工程学院通知",
maintainers: ["Ji4n1ng"],
handler,
description: `| 通知公告 | 院所新闻 | 教学信息 | 学术动态 | 学院简报 |
| -------- | -------- | -------- | -------- | -------- |
| 0 | 1 | 2 | 3 | 4 |`
};
async function handler(ctx) {
const type = ctx.req.param("type") ? Number.parseInt(ctx.req.param("type")) : 0;
const link = new URL(urlList[type], host).href;
const $ = load((await got_default(link)).data);
let item = $("#page_list li a").toArray().map((e) => {
e = $(e);
return {
title: e.attr("title"),
link: e.attr("href")
};
});
item = await Promise.all(item.filter((e) => e.link.startsWith("../info") || e.link.startsWith("https://www.rd.sdu.edu.cn/")).map((item$1) => {
if (item$1.link.startsWith("../info")) item$1.link = new URL(item$1.link.slice("3"), host).href;
return cache_default.tryGet(item$1.link, async () => {
const $$1 = load((await got_default(item$1.link)).data);
const info = $$1("#show_info").text().split(/\s{4}/);
const date = info[0].split(":")[1];
item$1.title = $$1("#show_title").text().trim();
item$1.author = info[1].replace("作者:", "") || "山东大学机械工程学院";
$$1("#show_title, #show_info").remove();
item$1.description = $$1("form[name=_newscontent_fromname] div").html();
item$1.pubDate = timezone(parseDate(date), 8);
return item$1;
});
}));
return {
title: `山东大学机械工程学院${typelist[type]}`,
description: $("title").text(),
link,
item
};
}
//#endregion
export { route };