rsshub
Version:
Make RSS Great Again!
69 lines (67 loc) • 2.32 kB
JavaScript
import "./dist-Bog6z_OM.mjs";
import "./config-MQ-7ebJ_.mjs";
import "./logger-C4avouvV.mjs";
import "./ofetch-DKl_Ma9g.mjs";
import { t as parseDate } from "./parse-date-r5WDWHno.mjs";
import "./is-worker-DESPicPc.mjs";
import { t as cache_default } from "./cache-SV6W5EPy.mjs";
import "./helpers-Bo4JQYdN.mjs";
import { t as got_default } from "./got-CO-ndVl2.mjs";
import { t as timezone } from "./timezone-CA9Huotp.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 $ = load((await got_default(item.link)).data);
item.author = item.author ?? $(".author-info .name a").text().split("作者 : ")[1];
item.pubDate = timezone(parseDate($(".publish-time").first().contents().filter((_, e) => e.nodeType === 3).text().trim(), "YYYY-MM-DD HH:mm:ss"), 8);
item.description = $("article").html();
item.category = $(".tags a").toArray().map((item) => $(item).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 };