UNPKG

rsshub

Version:
68 lines (66 loc) 2.17 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { t as timezone } from "./timezone-D8cuwzTY.mjs"; import { load } from "cheerio"; //#region lib/routes/gov/shaanxi/kjt.ts const route = { path: "/shaanxi/kjt/:id?", categories: ["government"], example: "/gov/shaanxi/kjt", parameters: { id: "分类,见下表,默认为通知公告" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "省科学技术厅", maintainers: ["nczitzk"], handler, description: `| 科技头条 | 工作动态 | 基层科技 | 科技博览 | 媒体聚焦 | 通知公告 | | -------- | -------- | -------- | -------- | -------- | -------- | | 1061 | 24 | 27 | 25 | 28 | 221 |` }; async function handler(ctx) { const id = ctx.req.param("id") ?? "221"; const rootUrl = "https://kjt.shaanxi.gov.cn"; const currentUrl = `${rootUrl}/view/iList.jsp?cat_id=${id}`; const $ = load((await got_default({ method: "get", url: currentUrl })).data); let items = $(".textlist li a").toArray().map((item) => { item = $(item); return { title: item.text(), link: `${rootUrl}${item.attr("href")}`, pubDate: parseDate(item.prev().text()) }; }); items = await Promise.all(items.map((item) => cache_default.tryGet(item.link, async () => { const content = load((await got_default({ method: "get", url: item.link })).data); item.description = content(".info_content").html(); item.author = content("meta[name=\"Author\"]").attr("content"); item.pubDate = timezone(parseDate(content("meta[name=\"PubDate\"]").attr("content")), 8); return item; }))); return { title: `陕西省科学技术厅 - ${$(".catnm").text()}`, link: currentUrl, item: items }; } //#endregion export { route };