feat: crawl stock's hot statuses (#2995)
* crawl 36kr newsflashes * xueqiu hot statuses * crawl stock's hot statuses
This commit is contained in:
parent
4d6257af50
commit
1fa27701aa
|
|
@ -10,6 +10,7 @@ module.exports = async (ctx) => {
|
|||
announcement: '公告',
|
||||
news: '自选股新闻',
|
||||
research: '研报',
|
||||
all: 'all',
|
||||
};
|
||||
const source = typename[type];
|
||||
|
||||
|
|
@ -21,16 +22,27 @@ module.exports = async (ctx) => {
|
|||
|
||||
const $ = cheerio.load(res1.data); // 使用 cheerio 加载返回的 HTML
|
||||
const html_title = $('title').text();
|
||||
const stock_name = html_title.split(' ')[0];
|
||||
const stock_name = html_title.split('(')[0];
|
||||
|
||||
let query_url = 'https://xueqiu.com/statuses';
|
||||
if (source === 'all') {
|
||||
query_url += '/search.json';
|
||||
} else {
|
||||
query_url += '/stock_timeline.json';
|
||||
}
|
||||
|
||||
const res2 = await got({
|
||||
method: 'get',
|
||||
url: 'https://xueqiu.com/statuses/stock_timeline.json',
|
||||
url: query_url,
|
||||
params: {
|
||||
symbol_id: id,
|
||||
symbol: id,
|
||||
source: source,
|
||||
count: count,
|
||||
page: page,
|
||||
sort: 'alpha',
|
||||
comment: '0',
|
||||
hl: '0',
|
||||
},
|
||||
headers: {
|
||||
Cookie: token,
|
||||
|
|
@ -40,11 +52,11 @@ module.exports = async (ctx) => {
|
|||
|
||||
const data = res2.data.list;
|
||||
ctx.state.data = {
|
||||
title: `${stock_name} 的${source}`,
|
||||
title: `${stock_name}的${source}`,
|
||||
link: `https://xueqiu.com/S/${id}`,
|
||||
description: `${stock_name} 的${source}`,
|
||||
item: data.map((item) => ({
|
||||
title: item.title !== '' ? item.title : item.description.split('<a')[0],
|
||||
title: item.title !== '' ? item.title : item.description.replace(/<[^>]+>/g, '').slice(0, 30),
|
||||
description: item.description,
|
||||
pubDate: new Date(item.created_at).toUTCString(),
|
||||
link: `https://xueqiu.com${item.target}`,
|
||||
|
|
|
|||
Loading…
Reference in New Issue