rsshub
Version:
Make RSS Great Again!
75 lines (74 loc) • 1.96 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/cuit/cxxww.ts
const baseUrl = "https://www.cuit.edu.cn";
const route = {
path: "/cxxww/:category{.+}?",
categories: ["university"],
example: "/cuit/cxxww/zhxw",
parameters: { category: {
description: "分类",
options: [
{
value: "zhxw",
label: "综合新闻"
},
{
value: "tzgg",
label: "通知公告"
},
{
value: "cxyw",
label: "成信要闻"
},
{
value: "cxxs",
label: "成信学术"
},
{
value: "mtcx",
label: "媒体成信"
},
{
value: "cxwh/whhd",
label: "文化活动"
}
],
default: "zhxw"
} },
radar: [{ source: ["www.cuit.edu.cn/index/:category"] }],
name: "成信新闻网",
maintainers: ["luojunyuan"],
handler,
url: "www.cuit.edu.cn"
};
async function handler(ctx) {
const { category = "zhxw" } = ctx.req.param();
const link = `${baseUrl}/index/${category.replace(/\.htm$/, "")}.htm`;
const $ = load(await rofetch(link));
const list = $(".newlist1 ul.list li a").toArray().map((item) => {
const $item = $(item);
return {
title: $item.find("h3").text(),
link: new URL($item.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));
item.author = $(".conttime span").toArray().map((e) => $(e).text().trim()).find((text) => text.startsWith("作者"))?.slice(3);
item.description = $(".v_news_content").html();
return item;
})));
return {
title: $("head title").text(),
link,
language: "zh-CN",
item: items
};
}
//#endregion
export { route };