UNPKG

rsshub

Version:
38 lines (37 loc) 1.21 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/rmlt/idea.ts const route = { path: "/idea", categories: ["new-media"], example: "/rmlt/idea", name: "思想理论", maintainers: ["nczitzk"], handler }; async function handler() { const currentUrl = `https://www.rmlt.com.cn/idea/`; const response = await rofetch(currentUrl); const $ = load(response); const list = $(".txt-list a").slice(0, 15).toArray().map((item) => ({ link: $(item).attr("href") })); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const detailResponse = await rofetch(item.link); const content = load(detailResponse); return { ...item, title: content(".article-title").text(), description: content(".article-content").html(), pubDate: timezone(parseDate(content(".date").text(), "YYYY-MM-DD HH:mm"), 8) }; }))); return { title: $("title").text(), link: currentUrl, item: items }; } //#endregion export { route };