UNPKG

rsshub

Version:
46 lines (45 loc) 1.46 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 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 currentUrl = `https://www.sznews.com/ranking/${dayjs().format("YYYY-MM-DD")}.json`; const list = (await rofetch(currentUrl)).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 };