UNPKG

rsshub

Version:
48 lines (47 loc) 1.95 kB
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs"; import { t as cache_default } from "./cache-CiDoUSLo.mjs"; import { load } from "cheerio"; //#region lib/routes/deloitte/industries.ts const route = { path: "/industries/:category?", categories: ["journal"], example: "/deloitte/industries/consumer", parameters: { category: "默认为 energy" }, name: "Articles", maintainers: ["laampui"], description: `| 消费行业 | 能源、资源及工业行业 | 金融服务行业 | 政府及公共服务 | 生命科学与医疗 | 科技、传媒及电信行业 | | -------- | -------------------- | ------------------ | ----------------- | ------------------------- | -------------------- | | consumer | energy | financial-services | government-public | life-sciences-health-care | tmt |`, handler }; async function handler(ctx) { const { category = "energy" } = ctx.req.param(); const rootUrl = "https://www.deloitte.com"; const currentUrl = `${rootUrl}/cn/zh/Industries/${category}/about.html`; const $ = load(await rofetch(currentUrl)); const cells = $(".cmp-mosaic-grid__cell"); const articles = cells.length ? cells.toArray().map((ele) => { const $ele = $(ele); return { title: $ele.find(".cmp-mosaic-grid__title h4").text(), link: new URL($ele.find("a").attr("href"), rootUrl).href }; }) : $(".cmp-promo-container__content a.cmp-promo-tracking").toArray().map((ele) => { const $ele = $(ele); return { title: $ele.find(".cmp-promo__content__title").text().trim(), link: new URL($ele.attr("href"), rootUrl).href }; }); const item = await Promise.all(articles.map((item) => cache_default.tryGet(item.link, async () => { item.description = load(await rofetch(item.link))(".cmp-text").html(); return item; }))); return { title: `Deloitte - ${$("title").text().split("|", 1)[0].trim()}`, link: currentUrl, item }; } //#endregion export { route };