rsshub
Version:
Make RSS Great Again!
83 lines (82 loc) • 2.35 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 { t as InvalidParameterError } from "./invalid-parameter-CGxhjomn.mjs";
import { load } from "cheerio";
//#region lib/routes/gov/gd/eea.ts
const route = {
path: "/eea/:caty",
categories: ["government"],
example: "/gov/gd/eea/kszs",
parameters: { caty: "资讯类别" },
name: "省教育考试院",
maintainers: ["icealtria"],
handler,
description: `| 考试招生 | 社会考试 | 招考公示 | 报考指南 | 要闻动态 | 公开专栏 | 政策文件 | 政策解读 |
| :------: | :------: | :------: | :------: | :------: | :------: | :------: | :------: |
| kszs | shks | zkgs | bkzn | ywdt | gkzl | zcwj | zcjd |`
};
const rootUrl = "https://eea.gd.gov.cn/";
const config = {
kszs: {
link: "/bmbk/kszs/",
title: "考试招生"
},
shks: {
link: "/shks/",
title: "社会考试"
},
zkgs: {
link: "/zwgk_zkgs/",
title: "招考公示"
},
bkzn: {
link: "/bmbk/bkzn/",
title: "报考指南"
},
ywdt: {
link: "/news/",
title: "要闻动态"
},
gkzl: {
link: "/zwgk/gkzl/",
title: "公开专栏"
},
zcwj: {
link: "/zwgk/zwwj/",
title: "政策文件"
},
zcjd: {
link: "/zcjd/",
title: "政策解读"
}
};
async function handler(ctx) {
const { caty } = ctx.req.param();
const cfg = config[caty];
if (!cfg) throw new InvalidParameterError("Bad category. See docs");
const currentUrl = new URL(cfg.link, rootUrl).href;
const $ = load(await rofetch(currentUrl));
const list = $("div.main>div.content>ul>li").toArray().map((item) => {
const a = $(item).find("a");
return {
title: a.text(),
link: a.attr("href")
};
});
const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
if (item.link.startsWith("https://mp.weixin.qq.com/")) return item;
const content = load(await rofetch(item.link));
item.description = content("div.article").html();
item.pubDate = timezone(parseDate(content("span.time").text()), 8);
return item;
})));
return {
title: `广东省教育考试院 - ${cfg.title}`,
link: currentUrl,
item: items
};
}
//#endregion
export { route };