UNPKG

rsshub

Version:
69 lines (67 loc) 2.34 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { t as timezone } from "./timezone-D8cuwzTY.mjs"; import { load } from "cheerio"; //#region lib/routes/yxrb/home.ts const baseUrl = "http://news.yxrb.net"; const route = { path: "/:category?", categories: ["game"], example: "/yxrb/info", parameters: { category: "分类,见下表,预设为 `info`" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["news.yxrb.net/:category", "news.yxrb.net/"], target: "/:category" }], name: "分类", maintainers: ["TonyRL"], handler, description: `| 资讯 | 访谈 | 服务 | 游理游据 | | ---- | ------- | ------- | -------- | | info | talking | service | comments |` }; async function handler(ctx) { const { category = "info" } = ctx.req.param(); const link = `${baseUrl}/${category}/`; const $ = load((await got_default(link)).data); const list = $(".channel-news .item").toArray().map((item) => { item = $(item); return { title: item.find(".title a").attr("title"), link: `${baseUrl}${item.find(".title a").attr("href")}`, author: item.find(".author a").text().split("作者 : ")[1] }; }); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const $$1 = load((await got_default(item.link)).data); item.author = item.author ?? $$1(".author-info .name a").text().split("作者 : ")[1]; item.pubDate = timezone(parseDate($$1(".publish-time").first().contents().filter((_, e) => e.nodeType === 3).text().trim(), "YYYY-MM-DD HH:mm:ss"), 8); item.description = $$1("article").html(); item.category = $$1(".tags a").toArray().map((item$1) => $$1(item$1).text()); return item; }))); return { title: $("head title").text(), description: $("head meta[name=description]").attr("content"), link, image: $(".channel-img img").attr("src"), item: items }; } //#endregion export { route };