UNPKG

rsshub

Version:
44 lines (43 loc) 1.42 kB
import { t as rofetch } from "./ofetch-C3ts-Hud.mjs"; import { t as cache_default } from "./cache-BkqOokyU.mjs"; import { n as getItem, t as baseUrl } from "./utils-DtivKT_C.mjs"; import { load } from "cheerio"; //#region lib/routes/qstheory/magazine.ts const route = { path: "/magazine/:magazine", categories: ["traditional-media"], example: "/qstheory/magazine/qs", parameters: { magazine: "刊物,`qs` 为求是,`hqwglist` 为红旗文稿" }, radar: [{ source: ["www.qstheory.cn/:magazine/mulu.htm"] }], name: "在线读刊", maintainers: ["TonyRL", "cscnk52"], handler }; async function handler(ctx) { const { magazine } = ctx.req.param(); const link = `${baseUrl}/${magazine}/mulu.htm`; const $ = load(await rofetch(link)); const $$ = load(await rofetch($(".booktitle a").toArray().map((item) => { const $item = $(item); return { title: $item.text(), link: new URL($item.attr("href"), baseUrl).href }; })[0].link)); const list = $$(".highlight a").toArray().map((item) => { const $item = $$(item); return { title: $item.text(), link: $item.attr("href") }; }).toReversed().filter((item) => item.title); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, () => getItem(item)))); return { title: $("head title").text(), link, image: new URL($(".book img").attr("src"), link).href, item: items }; } //#endregion export { route };