UNPKG

rsshub

Version:
48 lines (47 loc) 1.79 kB
import { t as rofetch } from "./ofetch-U0CdpE2g.mjs"; import { t as parseDate } from "./parse-date-3kcy2Eau.mjs"; import { t as cache_default } from "./cache-C1Y-9qDV.mjs"; import { t as timezone } from "./timezone-UiMFOuvL.mjs"; import { load } from "cheerio"; //#region lib/routes/mofa/mofa.ts const route = { path: "/", categories: ["government"], example: "/mofa", name: "Press conference", maintainers: ["sgqy"], handler }; const baseUrl = "https://www.mofa.go.jp"; const indexUrl = `${baseUrl}/mofaj/press/kaiken/bn/index.html`; const eraOffset = /* @__PURE__ */ new Map([ ["昭和", 1925], ["平成", 1988], ["令和", 2018] ]); async function handler() { const response = await rofetch(indexUrl); const $ = load(response); const detailUrls = $("dl.title-list dt.list-title a").toArray().filter((a) => $(a).text() === "テキスト版要旨").map((a) => new URL($(a).attr("href"), baseUrl).href); const items = await Promise.all(detailUrls.map((url) => cache_default.tryGet(url, async () => { const meeting = await rofetch(url); const $ = load(meeting); $("div.social-btn-top").remove(); const title3 = $("h3.title3"); const matches = title3.text().match(/((..)(\d+)年(\d+)月(\d+)日((.)曜日)(\d+)時(\d+)分.*)/); return { title: $("meta[property=\"og:title\"]").attr("content"), author: "外務省", pubDate: matches ? timezone(parseDate(`${Number.parseInt(matches[2]) + (eraOffset.get(matches[1]) ?? 0)}-${matches[3]}-${matches[4]} ${matches[6]}:${matches[7]}`), 9) : void 0, link: $("meta[property=\"og:url\"]").attr("content"), description: title3.html() + "<br/>" + $("div#maincontents").html() }; }))); return { title: "日本国外務省記者会見", link: indexUrl, item: items }; } //#endregion export { route };