rsshub
Version:
Make RSS Great Again!
65 lines (64 loc) • 2.08 kB
JavaScript
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs";
import { t as cache_default } from "./cache-CiDoUSLo.mjs";
import { load } from "cheerio";
//#region lib/routes/gov/shanxi/rst.ts
const route = {
path: "/rst/:category",
categories: ["government"],
example: "/gov/shanxi/rst/rsks-tzgg",
parameters: { category: "分类名" },
name: "人社厅",
maintainers: ["wolfyu1991"],
description: `| 通知公告 | 公务员考试 | 事业单位考试 | 专业技术人员资格考试 | 其他考试 |
| :-------: | :--------: | :----------: | :------------------: | :-------: |
| rsks-tzgg | rsks-gwyks | rsks-sydwks | rsks-zyjsryzgks | rsks-qtks |`,
handler
};
const categories = {
"rsks-tzgg": {
url: "http://rst.shanxi.gov.cn/rsks/tzgg/",
title: "山西人事考试专栏 - 通知公告"
},
"rsks-gwyks": {
url: "http://rst.shanxi.gov.cn/rsks/gwyks/",
title: "山西人事考试专栏 - 公务员考试"
},
"rsks-sydwks": {
url: "http://rst.shanxi.gov.cn/rsks/sydwks/",
title: "山西人事考试专栏 - 事业单位考试"
},
"rsks-zyjsryzgks": {
url: "http://rst.shanxi.gov.cn/rsks/zyjsryzgks/",
title: "山西人事考试专栏 - 专业技术人员资格考试"
},
"rsks-qtks": {
url: "http://rst.shanxi.gov.cn/rsks/qtks/",
title: "山西人事考试专栏 - 其他考试"
}
};
async function handler(ctx) {
const { category } = ctx.req.param();
const cfg = categories[category];
if (!cfg) throw new Error("pattern not matched");
const { url, title } = cfg;
const $ = load(await rofetch(url));
return {
title,
link: url,
item: await Promise.all($(".exam-main ul.list-items-box-inner li").toArray().map((item) => {
const $item = $(item);
const contenlUrl = $item.find("a").attr("href");
const link = new URL(contenlUrl, url).href;
return cache_default.tryGet(link, async () => {
const fullTextData = load(await rofetch(link));
return {
title: $item.find("a").text(),
description: fullTextData(".common-detail-inner").html(),
link
};
});
}))
};
}
//#endregion
export { route };