UNPKG

rsshub

Version:
63 lines (61 loc) 1.86 kB
import "./esm-shims-CzJ_djXG.mjs"; import { t as config } from "./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 * as cheerio from "cheerio"; import xxhash from "xxhash-wasm"; import sanitizeHtml from "sanitize-html"; //#region lib/routes/economist/espresso.ts const link = "https://www.economist.com/the-world-in-brief"; const route = { path: "/espresso", categories: ["traditional-media"], view: ViewType.Articles, example: "/economist/espresso", parameters: {}, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["economist.com/the-world-in-brief", "economist.com/espresso"] }], name: "Espresso", maintainers: ["TonyRL"], handler, url: "economist.com/the-world-in-brief" }; async function handler() { const { h64ToString } = await xxhash(); const { content, metadata } = (await cache_default.tryGet(link, async () => { const response = await ofetch_default(link); const $ = cheerio.load(response); return JSON.parse($("script#__NEXT_DATA__").text()); }, config.cache.routeExpire, false)).props.pageProps; const items = content.gobbets.map((item) => ({ link, title: sanitizeHtml(item, { allowedTags: [], allowedAttributes: {} }), pubDate: parseDate(content.datePublished), description: item, guid: `${link}#${h64ToString(item)}` })); return { title: metadata.title, link, description: metadata.description, language: "en-gb", image: metadata.imageUrl, item: items }; } //#endregion export { route };