diff --git a/docs/finance.md b/docs/finance.md
index 2fc47705c..8daa2c74c 100644
--- a/docs/finance.md
+++ b/docs/finance.md
@@ -34,7 +34,13 @@ pageClass: routes
### 深度
-
+
+
+| 要闻 | 股市 | 环球 | 公司 | 地产 | 券商 | 金融 | 汽车 | 科创版 |
+| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ------ |
+| 1000 | 1003 | 1007 | 1005 | 1006 | 1118 | 1032 | 1119 | 1111 |
+
+
## 富途牛牛
diff --git a/lib/router.js b/lib/router.js
index d621e0408..7718da024 100644
--- a/lib/router.js
+++ b/lib/router.js
@@ -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'));
diff --git a/lib/routes/cls/depth.js b/lib/routes/cls/depth.js
index af2412bee..3158b0d6e 100644
--- a/lib/routes/cls/depth.js
+++ b/lib/routes/cls/depth.js
@@ -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 docs');
+ }
+
+ 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,
};
};
diff --git a/lib/routes/cls/telegraph.js b/lib/routes/cls/telegraph.js
index 078ed5819..d1b6de771 100644
--- a/lib/routes/cls/telegraph.js
+++ b/lib/routes/cls/telegraph.js
@@ -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(),
}));