rsshub
Version:
Make RSS Great Again!
59 lines (58 loc) • 1.57 kB
JavaScript
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs";
import { t as parseDate } from "./parse-date-CjhZE69i.mjs";
import { t as cache_default } from "./cache-CiDoUSLo.mjs";
import { t as timezone } from "./timezone-DE--ze1V.mjs";
import { load } from "cheerio";
//#region lib/routes/sctu/jwc/index.ts
const route = {
path: "/jwc/:category?",
categories: ["university"],
example: "/sctu/jwc/tzgg",
parameters: { category: {
description: "分类",
options: [{
value: "tzgg",
label: "通知公告"
}, {
value: "xwdt",
label: "新闻动态"
}],
default: "tzgg"
} },
radar: [{
source: ["www.sctu.edu.cn/jwc/wenzhangg/:category.htm"],
target: "/jwc/:category"
}],
name: "教务处",
maintainers: ["talenHuang"],
handler,
url: "www.sctu.edu.cn/jwc/"
};
async function handler(ctx) {
const { category = "tzgg" } = ctx.req.param();
const link = `https://www.sctu.edu.cn/jwc/wenzhangg/${category}.htm`;
const $ = load(await rofetch(link));
const list = $(".main_conRCb ul li").toArray().map((item) => {
const $item = $(item);
const a = $item.find("a");
return {
title: a.text(),
link: new URL(a.attr("href"), link).href,
pubDate: timezone(parseDate($item.find("span").text(), "YYYY-MM-DD"), 8)
};
});
const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
const $ = load(await rofetch(item.link));
return {
...item,
description: $(".v_news_content").html()
};
})));
return {
title: $("head title").text(),
link,
item: items
};
}
//#endregion
export { route };