UNPKG

rsshub

Version:
80 lines (76 loc) 3.36 kB
import { t as cache_default } from "./cache-BkqOokyU.mjs"; import { t as got_default } from "./got-BTowW50G.mjs"; import { load } from "cheerio"; //#region lib/routes/dx2025/index.ts const route = { path: "/:type?/:category?", categories: ["new-media"], example: "/dx2025", parameters: { type: "内容类别,见下表,默认为空", category: "行业分类,见下表,默认为空" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "分类", maintainers: ["nczitzk"], handler, description: `内容类别 | 产业观察 | 行业报告 | 政策 | 数据 | | -------------------- | ---------------- | ------ | ---- | | industry-observation | industry-reports | policy | data | 行业分类 | 行业 | 行业名称 | | -------------------- | ----------------------------------------------------------------- | | 新一代信息技术 | next-generation-information-technology-industry-reports | | 高档数控机床和机器人 | high-grade-cnc-machine-tools-and-robots-industry-reports | | 航空航天装备 | aerospace-equipment-industry-reports | | 海工装备及高技术船舶 | marine-engineering-equipment-and-high-tech-ships-industry-reports | | 先进轨道交通装备 | advanced-rail-transportation-equipment-industry-reports | | 节能与新能源汽车 | energy-saving-and-new-energy-vehicles-industry-reports | | 电力装备 | electric-equipment-industry-reports | | 农机装备 | agricultural-machinery-equipment-industry-reports | | 新材料 | new-material-industry-reports | | 生物医药及医疗器械 | biomedicine-and-medical-devices-industry-reports | | 现代服务业 | modern-service-industry-industry-reports | | 制造业人才 | manufacturing-talent-industry-reports |` }; async function handler(ctx) { const type = ctx.req.param("type") || ""; const category = ctx.req.param("category") || ""; const currentUrl = `https://www.dx2025.com${type === "" ? "" : `/archives/${type === "tag" ? `tag${category === "" ? "" : `/${category}`}` : `category/${type}${category === "" ? "" : `/${category}`}`}`}`; const $ = load((await got_default({ method: "get", url: currentUrl })).data); const list = $(".entry-title a").slice(0, 10).toArray().map((item) => { const $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); item.author = content(".entry-author-name").text(); item.description = content(".bpp-post-content, .entry-content").html(); item.pubDate = new Date(content(".entry-date").attr("datetime")).toUTCString(); return item; }))); return { title: $("title").text(), link: currentUrl, item: items }; } //#endregion export { route };