rsshub
Version:
Make RSS Great Again!
101 lines (99 loc) • 2.66 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import "./ofetch-BIyrKU3Y.mjs";
import { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import "./cache-Bo__VnGm.mjs";
import "./helpers-DxBp0Pty.mjs";
import "./proxy-Db7uGcYb.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import "./puppeteer-DGmvuGvT.mjs";
import "./puppeteer-utils-BK3JC9qW.mjs";
import { t as parseToken } from "./cookies-ctB_rRKe.mjs";
import { load } from "cheerio";
import sanitizeHtml from "sanitize-html";
import queryString from "query-string";
//#region lib/routes/xueqiu/stock-info.ts
const route = {
path: "/stock_info/:id/:type?",
categories: ["finance"],
example: "/xueqiu/stock_info/SZ000002",
parameters: {
id: "股票代码(需要带上交易所)",
type: "动态的类型, 不填则为股票公告"
},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{
source: ["xueqiu.com/S/:id", "xueqiu.com/s/:id"],
target: "/stock_info/:id"
}],
name: "股票信息",
maintainers: ["YuYang"],
handler,
description: `| 公告 | 新闻 | 研报 |
| ------------ | ---- | -------- |
| announcement | news | research |`
};
async function handler(ctx) {
const id = ctx.req.param("id");
const type = ctx.req.param("type") || "announcement";
const count = 10;
const page = 1;
const source = {
announcement: "公告",
news: "自选股新闻",
research: "研报",
all: "all"
}[type];
const link = `https://xueqiu.com/S/${id}`;
const res1 = await got_default({
method: "get",
url: link
});
const token = await parseToken(link);
const stock_name = load(res1.data)(".stock-name").text().split("(")[0];
let query_url = "https://xueqiu.com/statuses";
query_url += source === "all" ? "/search.json" : "/stock_timeline.json";
const data = (await got_default({
method: "get",
url: query_url,
searchParams: queryString.stringify({
symbol_id: id,
symbol: id,
source,
count,
page,
sort: "alpha",
comment: "0",
hl: "0"
}),
headers: {
Cookie: token,
Referer: link
}
})).data.list;
return {
title: `${id} ${stock_name} - ${source}`,
link,
description: `${stock_name} - ${source}`,
item: data.map((item) => ({
title: item.title || sanitizeHtml(item.description, {
allowedTags: [],
allowedAttributes: {}
}),
description: item.description,
pubDate: parseDate(item.created_at),
link: `https://xueqiu.com${item.target}`
}))
};
}
//#endregion
export { route };