rsshub
Version:
Make RSS Great Again!
36 lines (35 loc) • 1.14 kB
JavaScript
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/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 $ = load(await rofetch(currentUrl));
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 content = load(await rofetch(item.link));
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 };