UNPKG

rsshub

Version:
84 lines (83 loc) 3.41 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 { load } from "cheerio"; //#region lib/routes/jfnet/industry-report.ts const HOST = "https://www.jfnet.or.jp"; const INDEX = `${HOST}/industry_report/?c=29&y=0`; const MEDIA_API = `${HOST}/wp-json/wp/v2/media?search=getujidata&per_page=100&_fields=date,source_url`; /** * Index rows (`div.flex.items-center.border-b`): [title, period '2026年7月', PDF link, Excel link]. * The monthly figures exist only inside the PDF / XLS (no HTML table), so the item carries the files. */ const parseIndex = (html) => { const $ = load(html); return $("div.flex.items-center.border-b").toArray().map((row) => { const cols = $(row).children("div"); const title = cols.eq(0).text().trim(); const period = cols.eq(1).text().trim().match(/(\d{4})年(\d{1,2})月/); const pdf = $(row).find("a[href$=\".pdf\"]").attr("href"); const xls = $(row).find("a[href$=\".xls\"], a[href$=\".xlsx\"]").attr("href"); if (!title || !period || !pdf) return null; return { title, source: "jfnet", survey: "外食産業市場動向調査", month: `${period[1]}-${period[2].padStart(2, "0")}`, pdf: new URL(pdf, HOST).href, xls: xls ? new URL(xls, HOST).href : null }; }).filter((r) => r !== null); }; const handler = async () => { const [entries, media] = await Promise.all([cache_default.tryGet(INDEX, async () => parseIndex(await rofetch(INDEX))), cache_default.tryGet(MEDIA_API, async () => { const list = await rofetch(MEDIA_API); return Object.fromEntries(list.map((m) => [m.source_url, m.date])); })]); const items = entries.map((e) => { const releasedAt = media[e.pdf] ?? null; const [year, month] = e.month.split("-", 2); const label = `${year}${Number(month)}月度`; return { title: `${e.survey} ${label}`, link: e.pdf, guid: e.pdf, pubDate: releasedAt === null ? void 0 : parseDate(releasedAt), description: `${e.survey}(月次レポート) ${label} — <a href="${e.pdf}">PDF</a>${e.xls ? ` / <a href="${e.xls}">Excel</a>` : ""}`, _extra: { ...e, title: void 0, released_at: releasedAt } }; }); return { title: "日本フードサービス協会 外食産業市場動向調査(月次)", link: INDEX, language: "ja", item: items }; }; const route = { path: "/industry-report", name: "外食産業市場動向調査(月次)", url: "www.jfnet.or.jp", maintainers: ["pseudoyu"], handler, example: "/jfnet/industry-report", parameters: {}, description: `Monthly releases of the 外食産業市場動向調査 from [業界データ](${HOST}/industry_report/). One item per survey month linking the PDF and Excel files; \`_extra\` carries \`month\` (YYYY-MM), \`pdf\`, \`xls\` and \`released_at\` (the file's upload date from the site's WordPress media API). The segment figures (売上高・客数・客単価 前年同月比) are only published inside the files and are not extracted: the site's 利用規約 reserves reproduction of its 資料 to prior permission.`, categories: ["finance"], features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportRadar: true }, radar: [{ source: ["www.jfnet.or.jp/industry_report"], target: "/industry-report" }] }; //#endregion export { handler, route };