rsshub
Version:
Make RSS Great Again!
81 lines (78 loc) • 2.54 kB
JavaScript
import { n as init_esm_shims, t as __dirname } from "./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 art } from "./render-BQo6B4tL.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import { t as timezone } from "./timezone-D8cuwzTY.mjs";
import path from "node:path";
import { load } from "cheerio";
//#region lib/routes/ccf/tfbd/utils.ts
init_esm_shims();
const base = "http://tfbd.ccf.org.cn";
const urlBase = (caty, id) => `http://tfbd.ccf.org.cn/tfbd/${caty}/${id}/`;
const renderDesc = (desc) => art(path.join(__dirname, "templates/description-a3d04f77.art"), { desc });
const detailPage = (e, cache) => cache.tryGet(e.link, async () => {
e.description = load((await got_default(e.link)).data)("div.articleCon").html();
return e;
});
const fetchAllArticles = (data) => {
const $ = load(data);
return $("div.file-list div.article-item").toArray().map((e) => {
const c = $(e);
return {
title: c.find("h3 a[href]").text().trim(),
link: base + c.find("h3 a[href]").attr("href"),
pubDate: timezone(parseDate(c.find("p").text().trim(), "YYYY-MM-DD"), 8)
};
});
};
var utils_default = {
BASE: base,
urlBase,
fetchAllArticles,
detailPage,
renderDesc
};
//#endregion
//#region lib/routes/ccf/tfbd/index.ts
const route = {
path: "/tfbd/:caty/:id",
categories: ["study"],
example: "/ccf/tfbd/xwdt/tzgg",
parameters: {
caty: "主分类,可在 URL 找到",
id: "子分类,可在 URL 找到"
},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["tfbd.ccf.org.cn/tfbd/:caty/:id", "tfbd.ccf.org.cn/"] }],
name: "大数据专家委员会",
maintainers: ["tudou027"],
handler
};
async function handler(ctx) {
const base$1 = utils_default.urlBase(ctx.req.param("caty"), ctx.req.param("id"));
const res = await got_default(base$1);
const info = utils_default.fetchAllArticles(res.data);
const $ = load(res.data);
const details = await Promise.all(info.map((e) => utils_default.detailPage(e, cache_default)));
ctx.set("json", { info });
return {
title: "大数据专家委员会 - " + $(".position a:last-child").text(),
link: base$1,
item: details
};
}
//#endregion
export { route };