UNPKG

rsshub

Version:
39 lines (38 loc) 1.15 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 { load } from "cheerio"; //#region lib/routes/cgtn/opinions.ts const route = { path: "/opinions", categories: ["new-media"], example: "/cgtn/opinions", name: "Opinions", maintainers: ["nczitzk"], handler }; async function handler() { const rootUrl = "https://www.cgtn.com/opinions"; const $ = load(await rofetch(rootUrl)); $(".cg-pic").parent().remove(); const list = $(".cg-title h3").toArray().slice(0, 15).map((item) => { const a = $(item).find("a"); return { title: a.text(), link: a.attr("href"), pubDate: parseDate(Number.parseInt(a.attr("data-time"))) }; }); return { title: "CGTN - Opinions", link: rootUrl, item: await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const content = load(await rofetch(item.link)); item.author = content(".news-author-name").text(); item.description = content("#cmsMainContent").html() ?? void 0; return item; }))) }; } //#endregion export { route };