UNPKG

rsshub

Version:
38 lines (37 loc) 1.09 kB
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs"; import { t as config } from "./config-Bpyy15zS.mjs"; import { load } from "cheerio"; import sanitizeHtml from "sanitize-html"; //#region lib/routes/uukanshu/index.ts const route = { path: "/:uid", categories: ["reading"], example: "/uukanshu/18893", parameters: { uid: "小说 id, 可在对应小说页 URL 中找到" }, name: "小说更新", maintainers: ["bott0n"], handler }; async function handler(ctx) { const { uid } = ctx.req.param(); const link = `https://uukanshu.cc/book/${uid}/`; const $ = load(await rofetch(link, { headers: { "user-agent": config.trueUA } })); return { title: `UU看书 ${$("h1.booktitle").text()}`, link, description: sanitizeHtml($(".bookintro").text(), { allowedTags: [], allowedAttributes: {} }), image: $(".bookcover>img").attr("src"), item: $(".chapterlist dd a").toArray().map((item) => { const $item = $(item); return { title: $item.text(), link: `https://uukanshu.cc${$item.attr("href")}` }; }).toReversed() }; } //#endregion export { route };