UNPKG

rsshub

Version:
43 lines (42 loc) 1.4 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/mnd/index.ts const route = { path: "/", categories: ["government"], example: "/gov/mnd", radar: [{ source: ["www.mnd.gov.tw/newslist"] }], name: "即時軍事動態", maintainers: ["nczitzk"], handler, url: "www.mnd.gov.tw/newslist" }; async function handler() { const rootUrl = "https://www.mnd.gov.tw"; const link = `${rootUrl}/newslist`; const $ = load(await rofetch(link)); const list = $("a.news_list").toArray().map((item) => { const $item = $(item); const dateSplit = $item.find(".date").text().split("."); dateSplit[0] = (Number.parseInt(dateSplit[0]) + 1911).toString(); return { title: $item.find(".title").text(), link: new URL($item.attr("href"), rootUrl).href, pubDate: timezone(parseDate(dateSplit.join("-")), 8), category: [$item.find(".category").text()] }; }); return { title: "即時軍事動態 - 中華民國國防部", link, item: await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { item.description = load(await rofetch(item.link))("div.maincontent").html(); return item; }))) }; } //#endregion export { route };