feat: add 财联社电报 & 深度 (#4924)

Co-authored-by: DIYgod <diy.d.god@gmail.com>
This commit is contained in:
Ethan Shen
2020-06-07 23:43:42 +08:00
committed by GitHub
co-authored by DIYgod
parent c39cf4e729
commit ad76a4e6db
4 changed files with 69 additions and 0 deletions
+10
View File
@@ -26,6 +26,16 @@ pageClass: routes
| -------- | -------- | -------- | -------- | -------- | -------- | -------- | ---------- |
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
## 财联社
### 电报
<Route author="nczitzk" example="/cls/telegragh" path="/cls/telegragh"/>
### 深度
<Route author="nczitzk" example="/cls/depth" path="/cls/depth"/>
## 淘股吧股票论坛
### 论坛总版
+4
View File
@@ -2814,6 +2814,10 @@ router.get('/gov/caict/bps', require('./routes/gov/caict/bps'));
router.get('/gov/caict/qwsj', require('./routes/gov/caict/qwsj'));
router.get('/gov/caict/caictgd', require('./routes/gov/caict/caictgd'));
// 财联社
router.get('/cls/telegraph', require('./routes/cls/telegraph'));
router.get('/cls/depth', require('./routes/cls/depth'));
// hentai-cosplays
router.get('/hentai-cosplays/:type?/:name?', require('./routes/hentai-cosplays/hentai-cosplays'));
router.get('/porn-images-xxx/:type?/:name?', require('./routes/hentai-cosplays/porn-images-xxx'));
+34
View File
@@ -0,0 +1,34 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const link = `https://www.cls.cn/depth`;
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}`,
pubDate: new Date(item.ctime * 1000).toUTCString(),
}));
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;
})
)
),
};
};
+21
View File
@@ -0,0 +1,21 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
const link = `https://www.cls.cn/nodeapi/telegraphs?&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,
description: item.content,
pubDate: new Date(item.ctime * 1000).toUTCString(),
}));
ctx.state.data = {
title: `财联社 - 电报`,
link: 'https://www.cls.cn/telegraph',
item: list,
};
};