rsshub
Version:
Make RSS Great Again!
69 lines (67 loc) • 1.95 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import { t as ViewType } from "./types-D84BRIt4.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import "./ofetch-BIyrKU3Y.mjs";
import { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import "./helpers-DxBp0Pty.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import { t as timezone } from "./timezone-D8cuwzTY.mjs";
//#region lib/routes/eastmoney/search/index.ts
const route = {
path: "/search/:keyword",
categories: ["finance"],
view: ViewType.Articles,
example: "/eastmoney/search/web3",
parameters: { keyword: "关键词,可以设置为自己需要检索的关键词" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
name: "搜索",
maintainers: ["drgnchan"],
handler
};
async function handler(ctx) {
const keyword = ctx.req.param("keyword");
const link = `https://so.eastmoney.com/News/s?KeyWord=${keyword}`;
const body = {
uid: "",
keyword,
type: ["cmsArticleWebOld"],
client: "web",
clientType: "web",
clientVersion: "curr",
params: { cmsArticleWebOld: {
searchScope: "default",
sort: "default",
pageIndex: 1,
pageSize: 10,
preTag: "<em>",
postTag: "</em>"
} }
};
const extractedText = (await got_default(`https://search-api-web.eastmoney.com/search/jsonp`, { searchParams: {
cb: `jQuery${("3.5.1" + Math.random()).replaceAll(/\D/g, "")}_${Date.now()}`,
param: JSON.stringify(body)
} })).data.match(/jQuery\d+_\d+\((.*)\)/)[1];
const items = JSON.parse(extractedText).result.cmsArticleWebOld.map((item) => ({
title: item.title,
description: item.content,
pubDate: timezone(parseDate(item.date), 8),
link: item.url,
author: item.mediaName
}));
return {
title: `东方财富网 - 搜索'${keyword}'`,
link,
item: items
};
}
//#endregion
export { route };