UNPKG

rsshub

Version:
57 lines (56 loc) 2 kB
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/gov/hebei/tyjrswt.ts const route = { path: "/tyjrswt/:type", categories: ["government"], example: "/gov/hebei/tyjrswt/sxxx", parameters: { type: "分类名" }, name: "退役军人事务厅", maintainers: ["sunshinenny"], handler, description: `| 省部要闻 | 厅内信息 | 市县信息 | | :------: | :------: | :------: | | ywgz | tnxx | sxxx |` }; const rootUrl = "https://tyjrswt.hebei.gov.cn"; function loadDetail(link) { return cache_default.tryGet(link, async () => { const $ = load(await rofetch(link)); const title = $("h3").text(); const introduce = $("body > div.container.mt40 > div > div > div.m-lg.info-style-content").html(); const temp = $("body > div.container.mt40 > div > div > div.m-lg.text-center > div.m-b-sm").text().replaceAll(/[\n\r]/g, ""); return { title, description: introduce, link, pubDate: timezone(parseDate(temp.slice(temp.indexOf("发布时间") + 5, temp.indexOf("信息来源")).trim() + ":00"), 8), author: temp.slice(temp.indexOf("信息来源") + 5, temp.indexOf("阅读次数")).trim() }; }); } async function handler(ctx) { const { type } = ctx.req.param(); const host = `${rootUrl}/gk2/${type}/`; const $ = load(await rofetch(host)); const list = $(`#${type}_list > li > a`).toArray(); const items = await Promise.all(list.map(async (item) => { const itemUrl = new URL($(item).attr("href"), host).href; return { guid: itemUrl, ...await loadDetail(itemUrl) }; })); const typeName = $("h3").text(); return { title: `河北省退伍军人事务厅 - ${typeName}`, link: host, description: `河北省退伍军人事务厅 - ${typeName} 更新提示`, item: items }; } //#endregion export { route };