UNPKG

rsshub

Version:
39 lines (37 loc) 1.23 kB
import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { load } from "cheerio"; //#region lib/routes/sobooks/utils.ts const utils = async (ctx, currentUrl) => { currentUrl = `https://www.sobooks.net/${currentUrl}`; const $ = load((await got_default({ method: "get", url: currentUrl })).data); const list = $(".card-item h3 a").slice(0, 15).toArray().map((item) => { 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 content = load((await got_default({ method: "get", url: item.link })).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 }; }; var utils_default = utils; //#endregion export { utils_default as t };