UNPKG

rsshub

Version:
45 lines (44 loc) 1.36 kB
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs"; import { t as parseDate } from "./parse-date-CjhZE69i.mjs"; import { t as cache_default } from "./cache-CiDoUSLo.mjs"; import { t as timezone } from "./timezone-DE--ze1V.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 $ = load(await rofetch(item.url)); 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 };