UNPKG

rsshub

Version:
42 lines (41 loc) 1.57 kB
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs"; import { t as parseDate } from "./parse-date-CjhZE69i.mjs"; import { t as PRESETS } from "./header-generator-DACPoxdp.mjs"; import { t as cache_default } from "./cache-CiDoUSLo.mjs"; import { load } from "cheerio"; //#region lib/routes/dcinside/board.ts const route = { path: "/board/:id", categories: ["other"], example: "/dcinside/board/programming", parameters: { id: "board id" }, name: "board", maintainers: ["zfanta"], handler }; const domain = "https://m.dcinside.com"; async function handler(ctx) { const { id } = ctx.req.param(); const link = `${domain}/board/${id}`; const $ = load(await rofetch(link, { headerGeneratorOptions: PRESETS.MODERN_ANDROID })); const items = await Promise.all($("body > div > div > div > section > ul.gall-detail-lst > li:not([class]) > div > a.lt").toArray().map((row) => { const itemLink = row.attribs.href; return cache_default.tryGet(itemLink, async () => { const content = load(await rofetch(itemLink, { headerGeneratorOptions: PRESETS.MODERN_ANDROID })); return { title: content("head title").text().trim(), pubDate: parseDate(content("body > div.container > div > div > section > div.gallview-tit-box > div > ul > li:nth-child(2)").text()), link: itemLink, description: content("body > div.container > div > div > section > div.gall-thum-btm > div > div.thum-txt").html() }; }); })); return { title: $("head title").text(), description: $("head title").text(), link, item: items }; } //#endregion export { route };