UNPKG

rsshub

Version:
80 lines (78 loc) 2.45 kB
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 path from "node:path"; import { load } from "cheerio"; //#region lib/routes/ccf/ccfcv/index.ts init_esm_shims(); const rootUrl = "https://tc.ccf.org.cn"; const cateTitleMap = { xsdt: { xsqy: "学术前沿", rdzw: "热点征文", xshy: "学术会议" } }; const route = { path: "/ccfcv/:channel/:category", categories: ["study"], example: "/ccf/ccfcv/xsdt/xsqy", parameters: { channel: "频道,仅支持 `xsdt`", category: "分类,见下表,亦可在网站 url 里找到" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "计算机视觉专委会 - 学术动态 - 分类", maintainers: ["elxy"], handler, description: `| 学术前沿 | 热点征文 | 学术会议 | | -------- | -------- | -------- | | xsqy | rdzw | xshy |` }; async function handler(ctx) { const channel = ctx.req.param("channel"); const cate = ctx.req.param("category"); const url = `${rootUrl}/ccfcv/${channel}/${cate}/`; const $ = load((await got_default(url)).data); let items = $("div.article-item").toArray().map((item) => { item = $(item); return { title: item.find("h3 a").text(), link: (cate === "xsqy" ? rootUrl : "") + item.find("h3 a").attr("href"), pubDate: parseDate(item.find("div p").text()) }; }); if (cate === "xsqy") items = await Promise.all(items.map((item) => cache_default.tryGet(item.link, async () => { let detailResponse; try { detailResponse = await got_default(item.link); } catch { item.status = 404; } if (item.status !== 404) { const pdfUrl = load(detailResponse.data)("div.g-box1 p a").attr("href"); item.description = art(path.join(__dirname, "templates/description-d4b82bc0.art"), { pdfUrl }); } delete item.status; return item; }))); return { title: `计算机视觉专委 - ${cateTitleMap[channel][cate]}`, link: url, item: items }; } //#endregion export { route };