UNPKG

rsshub

Version:
39 lines (38 loc) 1.11 kB
import { t as rofetch } from "./ofetch-U0CdpE2g.mjs"; import { t as config } from "./config-BfTrYkQS.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 response = await rofetch(link, { headers: { "user-agent": config.trueUA } }); const $ = load(response); 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 };