UNPKG

rsshub

Version:
39 lines (38 loc) 1.26 kB
import { t as parseDate } from "./parse-date-3kcy2Eau.mjs"; import { t as cache_default } from "./cache-C1Y-9qDV.mjs"; import { t as got_default } from "./got-DUpa1V3-.mjs"; import { load } from "cheerio"; //#region lib/routes/sobooks/utils.ts const utils = async (ctx, currentUrl) => { currentUrl = `https://www.sobooks.net/${currentUrl}`; const response = await got_default({ method: "get", url: currentUrl }); const $ = load(response.data); const list = $(".card-item h3 a").slice(0, 15).toArray().map((item) => { const $item = $(item); return { title: $item.text(), link: $item.attr("href") }; }); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const detailResponse = await got_default({ method: "get", url: item.link }); const content = load(detailResponse.data); content(".e-secret, .article-social").remove(); item.description = content(".article-content").html(); item.pubDate = parseDate(content(".bookinfo ul li").eq(4).text().replace("时间:", "")); return item; }))); return { title: ($(".archive-header h1").text() ? $(".archive-header h1").text() + " - " : "") + "SoBooks", link: currentUrl, item: items }; }; //#endregion export { utils as t };