fix: 财联社电报 & 深度 (#5061)
This commit is contained in:
parent
62c8a45d1b
commit
c999b0a60a
|
|
@ -34,7 +34,13 @@ pageClass: routes
|
|||
|
||||
### 深度
|
||||
|
||||
<Route author="nczitzk" example="/cls/depth" path="/cls/depth"/>
|
||||
<Route author="nczitzk" example="/cls/depth/1000" path="/cls/depth/:caty" :paramsDesc="['分类代码,可在首页导航栏的目标网址 URL 中找到']">
|
||||
|
||||
| 要闻 | 股市 | 环球 | 公司 | 地产 | 券商 | 金融 | 汽车 | 科创版 |
|
||||
| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ------ |
|
||||
| 1000 | 1003 | 1007 | 1005 | 1006 | 1118 | 1032 | 1119 | 1111 |
|
||||
|
||||
</Route>
|
||||
|
||||
## 富途牛牛
|
||||
|
||||
|
|
|
|||
|
|
@ -2827,6 +2827,7 @@ router.get('/cs/news/:caty', require('./routes/cs/news'));
|
|||
// 财联社
|
||||
router.get('/cls/telegraph', require('./routes/cls/telegraph'));
|
||||
router.get('/cls/depth', require('./routes/cls/depth'));
|
||||
router.get('/cls/depth/:caty', require('./routes/cls/depth'));
|
||||
|
||||
// hentai-cosplays
|
||||
router.get('/hentai-cosplays/:type?/:name?', require('./routes/hentai-cosplays/hentai-cosplays'));
|
||||
|
|
|
|||
|
|
@ -1,34 +1,56 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const config = {
|
||||
'1000': '要闻',
|
||||
'1003': '股市',
|
||||
'1007': '环球',
|
||||
'1005': '公司',
|
||||
'1006': '地产',
|
||||
'1118': '券商',
|
||||
'1032': '金融',
|
||||
'1119': '汽车',
|
||||
'1111': '科创版',
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const link = `https://www.cls.cn/depth`;
|
||||
ctx.params.caty = ctx.params.caty || '1000';
|
||||
const title = config[ctx.params.caty];
|
||||
if (!title) {
|
||||
throw Error('Bad category. See <a href="https://docs.rsshub.app/finance.html#cai-lian-she-shen-du">docs</a>');
|
||||
}
|
||||
|
||||
const link = `https://www.cls.cn/v3/depth/home/assembled/${ctx.params.caty}?app=CailianpressWeb&os=web&sv=7.2.2&sign=6ac194f4b3b39d45631708474e058b73`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: link,
|
||||
});
|
||||
|
||||
const data = JSON.parse(response.data.match(/"depth":(.*?),"reference":/)[1]);
|
||||
|
||||
const list = data.dataList.map((item) => ({
|
||||
title: item.title,
|
||||
link: `https://www.cls.cn/depth/${item.article_id}`,
|
||||
const list = response.data.data.depth_list.map((item) => ({
|
||||
title: item.title || item.brief,
|
||||
link: `https://www.cls.cn/detail/${item.id}`,
|
||||
pubDate: new Date(item.ctime * 1000).toUTCString(),
|
||||
}));
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.description = content('div.detail-content').html();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `财联社 - 深度`,
|
||||
link: link,
|
||||
item: await Promise.all(
|
||||
list.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const contentResponse = await got({ method: 'get', url: item.link });
|
||||
const content = cheerio.load(contentResponse.data);
|
||||
item.description = content('div.thisContent').html();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
),
|
||||
title: `财联社 - ${title}`,
|
||||
link: 'https://www.cls.cn/telegraph',
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
const got = require('@/utils/got');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const link = `https://www.cls.cn/nodeapi/telegraphs?&rn=20`;
|
||||
const link = `https://www.cls.cn/nodeapi/updateTelegraphList?rn=20`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: link,
|
||||
});
|
||||
|
||||
const list = response.data.data.roll_data.map((item) => ({
|
||||
title: item.title ? item.title : item.content,
|
||||
title: item.title || item.content,
|
||||
description: item.content,
|
||||
pubDate: new Date(item.ctime * 1000).toUTCString(),
|
||||
}));
|
||||
|
|
|
|||
Loading…
Reference in New Issue