UNPKG

rsshub

Version:
39 lines (38 loc) 1.29 kB
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/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 $ = load(await rofetch(currentUrl)); 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 content = load(await rofetch(item.link, { headers: { Referer: currentUrl } })); item.description = content("#articleContent").html() ?? void 0; item.pubDate = timezone(parseDate(content("time[itemprop=\"datePublished\"]").text()), 8); return item; }))) }; } //#endregion export { route };