UNPKG

rsshub

Version:
80 lines (76 loc) 2.51 kB
import { n as init_esm_shims, t as __dirname } from "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as art } from "./render-BQo6B4tL.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { t as timezone } from "./timezone-D8cuwzTY.mjs"; import path from "node:path"; import { load } from "cheerio"; //#region lib/routes/gzdaily/app.ts init_esm_shims(); const route = { path: "/app/:column?", categories: ["traditional-media"], example: "/gzdaily/app/74", parameters: { column: "栏目 ID,点击对应栏目后在地址栏找到" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "客户端", maintainers: ["TimWu007"], handler, description: `::: tip 在北京时间深夜可能无法获取内容。 ::: 常用栏目 ID: | 栏目名 | ID | | ------ | ---- | | 首页 | 74 | | 时局 | 374 | | 广州 | 371 | | 大湾区 | 397 | | 城区 | 2980 |` }; async function handler(ctx) { const column = ctx.req.param("column") ?? 74; const { data: response } = await got_default(`https://app.gzdaily.cn/app_if/getArticles?columnId=${column}&page=1`); const list = response.list.filter((i) => i.newstype === 0).map((item) => ({ title: item.title, description: art(path.join(__dirname, "templates/description-60b509f9.art"), { thumb: item.picBig }), pubDate: timezone(parseDate(item.publishtime), 8), link: item.shareUrl, colName: item.colName, author: item.arthorName })); let colName = ""; 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); colName = colName === "" ? item.colName : colName; if (content(".abstract").text()) { content(".abstract").find("span").remove(); item.description += "<blockquote>" + content(".abstract").text() + "</blockquote>"; } item.description += content(".article").html() ?? ""; return item; }))); return { title: `广州日报客户端 - ${colName}`, link: `https://www.gzdaily.cn/amucsite/web/index.html#/home/${column}`, item: items }; } //#endregion export { route };