rsshub
Version:
Make RSS Great Again!
73 lines (72 loc) • 2.53 kB
JavaScript
import { t as got_default } from "./got-BTowW50G.mjs";
import { load } from "cheerio";
//#region lib/routes/zzu/sxy.ts
const route = {
path: "/sxy/:type",
categories: ["university"],
example: "/zzu/sxy/xyxw",
parameters: { type: "分类名" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["www5.zzu.edu.cn/sxy/"] }],
name: "郑大商学院",
maintainers: ["amandus1990"],
handler,
description: `| 学院新闻 | 通知公告 | 教学科研 | 党工团学 | 讲座报告 | 学者观点 |
| -------- | -------- | -------- | -------- | -------- | -------- |
| xyxw | tzgg | jxky | dgtx | jzbg | xzgd |`
};
async function handler(ctx) {
const type = ctx.req.param("type");
const typeDict = {
xyxw: ["学院新闻", "https://www5.zzu.edu.cn/sxy/index/xyxw.htm"],
tzgg: ["通知公告", "https://www5.zzu.edu.cn/sxy/index/tzgg.htm"],
jxky: ["教学科研", "https://www5.zzu.edu.cn/sxy/index/jxky.htm"],
dgtx: ["党工团学", "https://www5.zzu.edu.cn/sxy/index/dgtx.htm"],
jzbg: ["讲座报告", "https://www5.zzu.edu.cn/sxy/index/jzbg.htm"],
xzgd: ["学者观点", "https://www5.zzu.edu.cn/sxy/index/xzgd.htm"]
};
const $ = load((await got_default(typeDict[type][1])).data);
const list = type === "xyxw" ? parseXyxwList($, typeDict, type) : parseOtherList($, typeDict, type);
return {
title: `郑大商学院-${typeDict[type][0]}`,
link: typeDict[type][1],
item: list
};
}
function parseXyxwList($, typeDict, type) {
return $("section.n_titu ul li").toArray().slice(0, 6).map((element) => {
const $element = $(element);
const $link = $element.find("a");
const link = new URL($link.attr("href"), typeDict[type][1]).href;
const title = $link.attr("title") || $link.text().trim();
const description = $element.find(".right .con p").text().trim();
const monthDay = $element.find(".time_con h3").text();
return {
title,
link,
pubDate: `${$element.find(".time_con h6").text()}-${monthDay}`,
description
};
});
}
function parseOtherList($, typeDict, type) {
return $(".n_notice ul.ul li").toArray().slice(0, 16).map((element) => {
const $element = $(element);
const $link = $element.find("a");
const link = new URL($link.attr("href"), typeDict[type][1]).href;
return {
title: $link.attr("title"),
link,
pubDate: $element.find("span.span01").text() || null
};
});
}
//#endregion
export { route };