UNPKG

rsshub

Version:
64 lines (63 loc) 2.17 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/mva/index.ts const route = { path: "/:type", categories: ["government"], example: "/gov/mva/bnxx", parameters: { type: "分类名" }, name: "中华人民共和国退役军人事务部", maintainers: ["sunshinenny"], handler, description: `| 部内信息 | 政策解读 | | :------: | :------: | | bnxx | zcjd |` }; function loadDetail(link) { return cache_default.tryGet(link, async () => { const $ = load(await rofetch(link)); const title = $("#main > div.outerlayer > div > div > h2 > p").text(); const introduce = $("#div_zhengwen > div").html(); const info = $("#main > div.outerlayer > div > div > div.article-info").contents().first().text(); return { title, description: introduce, link, pubDate: timezone(parseDate(info.slice(info.indexOf("时间:") + 3, info.indexOf("来源:")).trim().replace("年", "-").replace("月", "-").replace("日", "") + ":00"), 8), author: info.slice(info.indexOf("来源:") + 3).trim() }; }); } const pages = { bnxx: "https://www.mva.gov.cn/sy/xx/bnxx/", zcjd: "https://www.mva.gov.cn/jiedu/zcjd/" }; async function handler(ctx) { const { type } = ctx.req.param(); const checkType = { bnxx: "部内信息", zcjd: "政策解读" }; const page = pages[type]; const $ = load(await rofetch(page)); const list = $("#main > div.overview.container.clearfix > div.overview-right.fr > div > div.public_list_team > ul > li > a").toArray(); const items = await Promise.all(list.map(async (item) => { const itemUrl = new URL($(item).attr("href"), page).href; return { link: itemUrl, guid: itemUrl, ...await loadDetail(itemUrl) }; })); return { title: `中华人民共和国退役军人事务部 - ${checkType[type]}`, link: page, description: `中华人民共和国退役军人事务部 - ${checkType[type]} 更新提示`, item: items }; } //#endregion export { route };