rsshub
Version:
Make RSS Great Again!
54 lines (53 loc) • 1.98 kB
JavaScript
import "./types-DNj6Etbg.mjs";
import { t as parseDate } from "./parse-date-CjhZE69i.mjs";
import { t as cache_default } from "./cache-CiDoUSLo.mjs";
import { t as got_default } from "./got-BDnf4rdT.mjs";
import { load } from "cheerio";
//#region lib/routes/schwabnetwork/markets.tsx
const route = {
path: "/markets",
categories: ["finance"],
view: 5,
example: "/schwabnetwork/markets",
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["schwabnetwork.com/markets"] }],
name: "市场新闻",
maintainers: ["hutianyu2006"],
handler,
url: "schwabnetwork.com/markets"
};
async function handler() {
const url = "https://www.schwabnetwork.com/markets";
const nextDataRaw = load((await got_default(url)).body)("#__NEXT_DATA__").text();
const nextData = JSON.parse(nextDataRaw || "{}");
const items = Object.values(nextData.props.pageProps.context.META_CATEGORY_ARTICLES.value).flatMap((articles) => articles.map((article) => cache_default.tryGet(`schwabnetwork:markets:${article.id}`, async () => {
const nextDataRaw = load((await got_default(`https://www.schwabnetwork.com${article.href}`)).body)("#__NEXT_DATA__").text();
const articleContent = (JSON.parse(nextDataRaw || "{}").props.pageProps.context.articleContent.value.content.blocks ?? []).map((block) => {
if (block.type === "text") return block.content;
return "";
}).join("");
return {
title: article.name,
link: `https://www.schwabnetwork.com${article.href}`,
description: articleContent,
guid: article.id,
pubDate: parseDate(article.date)
};
})));
const resolvedItems = await Promise.all(items);
return {
title: "Schwab Network - Markets Overview",
description: "Latest news and updates from Schwab Network.",
link: url,
item: new Map(resolvedItems.map((item) => [item.guid, item])).values().toArray()
};
}
//#endregion
export { route };