UNPKG

rsshub

Version:
57 lines (54 loc) 1.86 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import { load } from "cheerio"; //#region lib/routes/bjx/fd.ts const route = { path: "/fd/:type", categories: ["traditional-media"], example: "/bjx/fd/yw", parameters: { type: "文章分类,详见下表" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "风电", maintainers: ["hualiong"], description: `\`:type\` 类型可选如下 | 要闻 | 政策 | 数据 | 市场 | 企业 | 招标 | 技术 | 报道 | | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | | yw | zc | sj | sc | mq | zb | js | bd |`, handler: async (ctx) => { const type = ctx.req.param("type"); const $ = load(await ofetch_default(`https://fd.bjx.com.cn/${type}/`)); const typeName = $("div.box2 em:last-child").text(); const list = $("div.cc-list-content ul li:nth-child(-n+20)").toArray().map((item) => { const each = $(item); return { title: each.find("a").attr("title"), link: each.find("a").attr("href"), pubDate: parseDate(each.find("span").text()) }; }); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { item.description = load(await ofetch_default(item.link))("#article_cont").html(); return item; }))); return { title: `北极星风力发电网${typeName}`, description: $("meta[name=\"Description\"]").attr("content"), link: `https://fd.bjx.com.cn/${type}/`, item: items }; } }; //#endregion export { route };