UNPKG

rsshub

Version:
69 lines (67 loc) 1.94 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import { t as logger_default } from "./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 got_default } from "./got-KxxWdaxq.mjs"; import { t as timezone } from "./timezone-D8cuwzTY.mjs"; import { load } from "cheerio"; //#region lib/routes/eastday/sh.ts const route = { path: "/sh", categories: ["traditional-media"], example: "/eastday/sh", parameters: {}, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["sh.eastday.com/"] }], name: "上海新闻", maintainers: ["saury"], handler, url: "sh.eastday.com/" }; async function handler() { const domain = "http://wap.eastday.com"; const response = await got_default({ method: "get", url: `https://apin.eastday.com/apiplus/special/specialnewslistbyurl?specialUrl=1632798465040016&skipCount=0&limitCount=20` }); const result = await Promise.all(response.data.data.list.map(async (item) => { const link = item.url; const entity = { title: item.title, description: item.abstracts, pubDate: timezone(parseDate(item.time), 8), link }; try { const cacheKey = `eastday_sh_${link}`; entity.description = await cache_default.tryGet(cacheKey, async () => { const $ = load((await got_default({ method: "get", url: link })).body); return $(".article_wrapper .mainLayer .content").html() || $(".contentBox .article .detail").html(); }); } catch (error) { logger_default.error(error); } return entity; })); return { title: `东方网-上海`, link: `${domain}/wap/sh.html`, item: result }; } //#endregion export { route };