rsshub
Version:
Make RSS Great Again!
77 lines (75 loc) • 2.35 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.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 { load } from "cheerio";
//#region lib/routes/jpmorganchase/research.ts
const base = "https://www.jpmorganchase.com";
const frontPageUrl = `${base}/institute/all-topics`;
const indexUrl = `${base}/services/json/v1/dynamic-grid.service/parent=jpmorganchase/global/US/en/home/institute/all-topics&comp=root/content-parsys/dynamic_grid&page=p1.json`;
const route = {
path: "/",
example: "/jpmorganchase",
categories: ["finance"],
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{
source: ["jpmorganchase.com/institute/all-topics"],
target: "/"
}],
name: "Research Topics",
maintainers: ["dousha"],
handler,
url: "www.jpmorganchase.com/institute/all-topics"
};
async function fetchIndexEntires() {
const response = await ofetch_default(indexUrl);
if (!("meta" in response)) return [];
const meta = response.meta;
const maxItemCount = Number(meta["partition-size"]);
return response.items.slice(0, maxItemCount);
}
function fetchDataItem(entry) {
const url = `${base}${entry.link}`;
return cache_default.tryGet(url, async () => {
let authors = [];
let description = "";
let category = [];
let articleDate = entry.date;
const pageContent = await ofetch_default(url);
if (pageContent.length > 0) {
const $ = load(pageContent);
category = [$(".eyebrow").text()];
authors = $(".author-name").toArray().map((el) => $(el).text().trim());
articleDate = $(".date").text().trim() || entry.date;
description = $(".root").children("div").children("div:eq(1)").html() || "";
}
return {
category,
author: authors.join(", "),
title: entry.title,
description,
link: url,
pubDate: parseDate(articleDate)
};
});
}
async function handler() {
const entires = await fetchIndexEntires();
return {
title: "All Topics - JPMorganChase Institute",
link: frontPageUrl,
item: await Promise.all(entires.map((it) => fetchDataItem(it)))
};
}
//#endregion
export { route };