feat: 又双叒叕更改股票路由 (#4093)
This commit is contained in:
parent
af48722ba9
commit
4bcaefa093
|
|
@ -42,7 +42,7 @@ module.exports = async (ctx) => {
|
|||
const name = $('.fullview-title b').text();
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${name} News by Finviz`,
|
||||
title: `${ctx.params.ticker} ${name} News by Finviz`,
|
||||
link,
|
||||
description: `A collection of ${name} news aggregated by Finviz.`,
|
||||
item,
|
||||
|
|
|
|||
|
|
@ -22,7 +22,9 @@ module.exports = async (ctx) => {
|
|||
const token = res1.headers['set-cookie'].find((s) => s.startsWith('xq_a_token=')).split(';')[0];
|
||||
|
||||
const $ = cheerio.load(res1.data); // 使用 cheerio 加载返回的 HTML
|
||||
const stock_name = $('.stock-name').text();
|
||||
const stock_name = $('.stock-name')
|
||||
.text()
|
||||
.split('(')[0];
|
||||
|
||||
let query_url = 'https://xueqiu.com/statuses';
|
||||
if (source === 'all') {
|
||||
|
|
@ -52,14 +54,20 @@ module.exports = async (ctx) => {
|
|||
|
||||
const data = res2.data.list;
|
||||
ctx.state.data = {
|
||||
title: `${stock_name} - ${source}`,
|
||||
title: `${id} ${stock_name} - ${source}`,
|
||||
link: `https://xueqiu.com/S/${id}`,
|
||||
description: `${stock_name} - ${source}`,
|
||||
item: data.map((item) => ({
|
||||
title: item.title !== '' ? item.title : item.description.replace(/<[^>]+>/g, ''),
|
||||
description: item.description,
|
||||
pubDate: new Date(item.created_at).toUTCString(),
|
||||
link: `https://xueqiu.com${item.target}`,
|
||||
})),
|
||||
item: data.map((item) => {
|
||||
let link = `https://xueqiu.com${item.target}`;
|
||||
if (item.quote_cards) {
|
||||
link = item.quote_cards[0].target_url;
|
||||
}
|
||||
return {
|
||||
title: item.title !== '' ? item.title : item.description.replace(/<[^>]+>/g, ''),
|
||||
description: item.description,
|
||||
pubDate: new Date(item.created_at).toUTCString(),
|
||||
link,
|
||||
};
|
||||
}),
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue