UNPKG

rsshub

Version:
58 lines (56 loc) 1.93 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { t as timezone } from "./timezone-D8cuwzTY.mjs"; import { load } from "cheerio"; //#region lib/routes/hunanpea/rsks.ts const route = { path: "/rsks/:guid", categories: ["study"], example: "/hunanpea/rsks/2f1a6239-b4dc-491b-92af-7d95e0f0543e", parameters: { guid: "分类 id,可在 URL 中找到" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["rsks.hunanpea.com/Category/:guid/ArticlesByCategory.do"] }], name: "公告", maintainers: ["TonyRL"], handler }; async function handler(ctx) { const baseUrl = "http://rsks.hunanpea.com"; const link = `${baseUrl}/Category/${ctx.req.param("guid")}/ArticlesByCategory.do?PageIndex=1`; const { data: response } = await got_default(link); const $ = load(response); const list = $("#column_content > ul > li").toArray().map((item) => { item = $(item); return { title: item.find("a").attr("title"), link: `${baseUrl}${item.find("a").attr("href").replace("ArticleDetail.do", "InternalArticleDetail.do?")}`, pubDate: timezone(parseDate(item.find("em").text()), 8) }; }); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const { data: response$1 } = await got_default(item.link); item.description = load(response$1)(".content_area").html(); return item; }))); return { title: `${$(".sitemap h2").text()} - ${$("head title").text()}`, link, item: items }; } //#endregion export { route };