rsshub
Version:
Make RSS Great Again!
77 lines (76 loc) • 2.04 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/bjeea/index.ts
const route = {
path: "/:type",
categories: ["government"],
example: "/bjeea/bjeeagg",
parameters: { type: "分类名" },
radar: [
{
source: ["www.bjeea.com/bjeeagg"],
target: "/bjeeagg"
},
{
source: ["www.bjeea.com/zkzc"],
target: "/zkzc"
},
{
source: ["www.bjeea.com/zkkd"],
target: "/zkkd"
}
],
name: "通知公告",
maintainers: ["gavin-k"],
handler,
description: `| 通知公告 | 招考政策 | 自考快递 |
| :------: | :------: | :------: |
| bjeeagg | zkzc | zkkd |`
};
const baseUrl = "https://www.bjeea.cn/";
const siteTitle = "北京教育考试院--";
const categoryMap = {
bjeeagg: {
title: "首页 / 通知公告",
suffix: "html/bjeeagg"
},
zkzc: {
title: "首页 / 招考政策",
suffix: "html/zkzc"
},
zkkd: {
title: "首页 / 自考快递",
suffix: "html/zkkd"
}
};
async function handler(ctx) {
const { type = "bjeeagg" } = ctx.req.param();
const $ = load(await rofetch(baseUrl + categoryMap[type].suffix));
const list = $("ul.com-list>li").toArray().map((item) => {
const $item = $(item);
const title = $item.find("a").text();
const link = new URL($item.find("a").attr("href"), baseUrl).href;
return {
title,
pubDate: timezone(parseDate($item.find("span").text()), 8),
link,
guid: link,
description: title
};
});
const result = await Promise.all(list.map((item) => item.link.startsWith(baseUrl) ? cache_default.tryGet(item.link, async () => {
item.description = load(await rofetch(item.link))("div.info-txt").html();
return item;
}) : item));
return {
title: siteTitle + categoryMap[type].title,
link: baseUrl,
description: siteTitle + categoryMap[type].title,
item: result
};
}
//#endregion
export { route };