rsshub
Version:
Make RSS Great Again!
41 lines (40 loc) • 1.36 kB
JavaScript
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/wenxuecity/news.ts
const route = {
path: "/news",
categories: ["bbs"],
example: "/wenxuecity/news",
name: "焦点新闻",
maintainers: ["nczitzk"],
handler
};
async function handler() {
const rootUrl = "https://www.wenxuecity.com";
const currentUrl = `${rootUrl}/news/`;
const response = await rofetch(currentUrl);
const $ = load(response);
const list = $("div.mainwrap div.block div.wrapper ul li a").toArray().slice(0, 15).map((item) => {
const $item = $(item);
return {
title: $item.text(),
link: `${rootUrl}${$item.attr("href")}`
};
});
return {
title: "焦点新闻 - 文学城",
link: currentUrl,
item: await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
const detailResponse = await rofetch(item.link, { headers: { Referer: currentUrl } });
const content = load(detailResponse);
item.description = content("#articleContent").html() ?? void 0;
item.pubDate = timezone(parseDate(content("time[itemprop=\"datePublished\"]").text()), 8);
return item;
})))
};
}
//#endregion
export { route };