UNPKG

rsshub

Version:
68 lines (66 loc) 2.36 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/moj/aac/news.ts const baseUrl = "https://www.aac.moj.gov.tw"; const route = { path: "/moj/aac/news/:type?", categories: ["government"], example: "/gov/moj/aac/news", parameters: { type: "資料大類,留空為全部" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "最新消息", maintainers: ["TonyRL"], handler, description: `| 全部 | 其他 | 採購公告 | 新聞稿 | 肅貪 | 預防 | 綜合 | 防疫專區 | | ---- | ---- | -------- | ------ | ---- | ---- | ---- | -------- | | | 02 | 01 | 06 | 05 | 04 | 03 | 99 |` }; async function handler(ctx) { const type = ctx.req.param("type"); const url = `${baseUrl}/7204/7246/?Page=1&PageSize=40${type ? `&type=${type}` : ""}`; const $ = load((await got_default(url)).data); $(".num").remove(); const list = $(".list ul li a").toArray().map((item) => { item = $(item); const isDownload = /檔案下載/.test(item.attr("title")); return { title: isDownload ? item.text().trim() : item.attr("title"), link: new URL(item.attr("href"), baseUrl).href, isDownload }; }); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { if (!item.isDownload) { const $$1 = load((await got_default(item.link)).data); item.pubDate = timezone(parseDate($$1(".info time").attr("datetime"), "YYYY-MM-DD HH:mm:ss"), 8); $$1(".info, button").remove(); item.description = $$1(".cp").html() + ($$1(".lightbox_slider").length ? $$1(".lightbox_slider").html() : "") + ($$1(".file_download").length ? $$1(".file_download").html() : ""); } delete item.isDownload; return item; }))); return { title: $("head title").text(), link: url, item: items, language: "zh-TW" }; } //#endregion export { route };