UNPKG

rsshub

Version:
79 lines (77 loc) 2.72 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import { t as ViewType } from "./types-D84BRIt4.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 { t as timezone } from "./timezone-D8cuwzTY.mjs"; import { load } from "cheerio"; //#region lib/routes/ce/district.ts const route = { path: "/district/:category?", name: "地方经济", url: "district.ce.cn", maintainers: ["cscnk52"], handler, example: "/ce/district", parameters: { category: "栏目标识,默认为 roll(即时新闻)" }, description: `| 即时新闻 | 经济动态 | 独家视角 | 专题 | 数说地方 | 地方播报 | 专稿 | 港澳台 | |----------|----------|----------|------|----------|----------|------|--------| | roll | jjdt | poll | ch | ssdf | dfbb | zg | gat |`, categories: ["traditional-media"], features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false, supportRadar: true }, radar: [ { source: ["district.ce.cn/newarea/:category/index.shtml"], target: "/district/:category?" }, { source: ["district.ce.cn/newarea/:category"], target: "/district/:category?" }, { source: ["district.ce.cn"], target: "/district" } ], view: ViewType.Articles }; async function handler(ctx) { const rootUrl = "http://district.ce.cn/"; const { category = "roll" } = ctx.req.param(); const url = `${rootUrl}newarea/${category}/index.shtml`; const GB2312Response = await ofetch_default(url, { responseType: "arrayBuffer" }); const $ = load(new TextDecoder("gb2312").decode(new Uint8Array(GB2312Response))); const bigTitle = $("div.channl a").eq(1).attr("title"); const list = $("div.sec_left li").toArray().map((e) => { const element = $(e); return { title: element.find("a").text().trim(), link: new URL(element.find("a").attr("href"), url).href }; }); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const GB2312Response$1 = await ofetch_default(item.link, { responseType: "arrayBuffer" }); const $$1 = load(new TextDecoder("gb2312").decode(new Uint8Array(GB2312Response$1))); item.pubDate = timezone(parseDate($$1("span#articleTime").text().trim(), "YYYY年MM月DD日 HH:mm"), 8); item.description = $$1("div.TRS_Editor").html(); return item; }))); return { title: `中国经济网地方经济 - ${bigTitle}`, link: url, item: items }; } //#endregion export { route };