UNPKG

rsshub

Version:
46 lines (45 loc) 1.41 kB
import { t as rofetch } from "./ofetch-U0CdpE2g.mjs"; import { t as parseDate } from "./parse-date-3kcy2Eau.mjs"; import { t as cache_default } from "./cache-C1Y-9qDV.mjs"; import { t as timezone } from "./timezone-UiMFOuvL.mjs"; import { load } from "cheerio"; //#region lib/routes/zsnews/index.ts const route = { path: "/index/:cateid", categories: ["traditional-media"], example: "/zsnews/index/35", parameters: { cateid: "类别" }, name: "中山网新闻", maintainers: ["laampui"], description: `| 35 | 36 | 37 | 38 | 39 | | ---- | ---- | ---- | ---- | ---- | | 本地 | 镇区 | 热点 | 社会 | 综合 |`, handler }; async function handler(ctx) { const { cateid = "35" } = ctx.req.param(); const response = await rofetch(`http://www.zsnews.cn/api/mobile/getlist.html?cateid=${cateid}`, { responseType: "json" }); return { title: "中山新闻", link: "https://www.zsnews.cn/", item: await Promise.all(response.map((item) => cache_default.tryGet(item.url, async () => { try { const detailResponse = await rofetch(item.url); const $ = load(detailResponse); return { ...item, description: $(".article-content").html(), pubDate: timezone(parseDate($(".article-meta span").first().text().slice(5)), 8), link: item.url }; } catch { return { ...item, link: item.url }; } }))) }; } //#endregion export { route };