UNPKG

rsshub

Version:
45 lines (44 loc) 1.43 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 dayjs from "dayjs"; import { load } from "cheerio"; //#region lib/routes/sznews/ranking.ts const route = { path: "/ranking", categories: ["new-media"], example: "/sznews/ranking", name: "排行榜", maintainers: ["nczitzk"], handler }; async function handler() { const list = (await rofetch(`https://www.sznews.com/ranking/${dayjs().format("YYYY-MM-DD")}.json`)).data.map((item) => ({ title: item.TITLE, link: item.URL.replace("http://", "https://") })); return { title: "焦点新闻 - 深圳新闻网", link: "http://news.sznews.com", item: await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { let link = item.link; let detailResponse = await rofetch(link); const fulltext = detailResponse.match(/<a href="(.*)">全文阅读<\/a>/); if (fulltext) { link = fulltext[1]; detailResponse = await rofetch(link); } const content = load(detailResponse); return { ...item, link, description: content(".article-content").html(), author: content(".a_source").text().replace("来源: ", ""), pubDate: timezone(parseDate(content(".a_time").text()), 8) }; }))) }; } //#endregion export { route };