UNPKG

rsshub

Version:
131 lines (129 loc) 3.98 kB
import { n as init_esm_shims, t as __dirname } from "./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 art } from "./render-BQo6B4tL.mjs"; import { t as timezone } from "./timezone-D8cuwzTY.mjs"; import path from "node:path"; import { load } from "cheerio"; //#region lib/routes/eeo/kuaixun.ts init_esm_shims(); const handler = async (ctx) => { const limit = Number.parseInt(ctx.req.query("limit") ?? "50", 10); const baseUrl = "https://www.eeo.com.cn"; const apiUrl = "https://app.eeo.com.cn"; const targetUrl = new URL("kuaixun/", baseUrl).href; const response = await ofetch_default(apiUrl, { query: { app: "article", controller: "index", action: "getMoreArticle", catid: 3690, uuid: "b048c7211db949eeb7443cd5b9b3bfe3", page: 1, pageSize: limit } }); const $ = load(await ofetch_default(targetUrl)); const language = $("html").attr("lang") ?? "en"; let items = []; items = response.data.slice(0, limit).map((item) => { const title = item.title; const description = art(path.join(__dirname, "templates/description-ca64252b.art"), { intro: item.description, description: item.content }); const pubDate = item.published; const linkUrl = item.url; const categories = [item.catname].filter(Boolean); const authors = item.author; const guid = item.contentid ? `eeo-${item.contentid}` : ""; const image = item.thumb; const updated = pubDate; return { title, description, pubDate: pubDate ? timezone(parseDate(pubDate), 8) : void 0, link: linkUrl, category: categories, author: authors, guid, id: guid, content: { html: description, text: description }, image, banner: image, updated: updated ? timezone(parseDate(updated), 8) : void 0, language }; }); items = await Promise.all(items.map((item) => { if (!item.link) return item; return cache_default.tryGet(item.link, async () => { const $$ = load(await ofetch_default(item.link)); const title = $$("h1").first().text() || $$("h2.title").text() || item.title; const description = item.description + art(path.join(__dirname, "templates/description-ca64252b.art"), { description: $$("div.xx_boxsing, div#mainBody").html() }); const pubDateStr = $$("h1").next().find("span").first().text() || $$("div.from").text(); const authors = $$("h1").next().contents().first().text() || $$("span.showMoreAuthor").text() || item.author; const upDatedStr = pubDateStr; const processedItem = { title, description, pubDate: pubDateStr ? timezone(parseDate(pubDateStr), 8) : item.pubDate, author: authors, content: { html: description, text: description }, updated: upDatedStr ? timezone(parseDate(upDatedStr), 8) : item.updated, language }; return { ...item, ...processedItem }; }); })); return { title: $("title").text(), description: $("meta[name=\"description\"]").attr("content"), link: targetUrl, item: items, allowEmpty: true, image: $("div.logo img").attr("src"), author: $("meta[name=\"author\"]").attr("content"), language, id: $("meta[property=\"og:url\"]").attr("content") }; }; const route = { path: "/kuaixun", name: "快讯", url: "www.eeo.com.cn", maintainers: ["nczitzk"], handler, example: "/eeo/kuaixun", parameters: void 0, description: void 0, categories: ["finance"], features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportRadar: true, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["www.eeo.com.cn/kuaixun/"], target: "/kuaixun" }], view: ViewType.Articles }; //#endregion export { handler, route };