feat: 新增 第一财经 直播区 (#2690)

Co-authored-by: DIYgod <diy.d.god@gmail.com>
This commit is contained in:
sanmmmm 2019-07-26 11:09:41 +08:00 committed by DIYgod
parent 023b3abb0c
commit d720d588d9
3 changed files with 42 additions and 0 deletions

View File

@ -124,6 +124,12 @@ Category 列表:
<Route author="EsuRt" example="/caixin/article" path="/caixin/article"/>
## 第一财经
### 直播区
<Route author="sanmmm" example="/yicai/brief" path="/yicai/brief" />
## 东方网
### 上海新闻

View File

@ -1562,6 +1562,9 @@ router.get('/10000link/news/:category?', require('./routes/10000link/news'));
// Artand
router.get('/artand/user/work/:uid', require('./routes/artand/user/work'));
// 第一财经
router.get('/yicai/brief', require('./routes/yicai/brief.js'));
// 一兜糖
router.get('/yidoutang/index', require('./routes/yidoutang/index.js'));
router.get('/yidoutang/guide', require('./routes/yidoutang/guide.js'));

33
lib/routes/yicai/brief.js Normal file
View File

@ -0,0 +1,33 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
const baseUrl = 'https://www.yicai.com';
const url = `${baseUrl}/api/ajax/getbrieflist`;
const query = {
pagesize: 30,
type: 0,
page: 0,
};
const response = await got(url, {
query,
});
const resList = response.data;
const item = resList.map((obj) => {
const { datekey, istop, url, newcontent, hm, indexTitle } = obj;
const dateStr = `${datekey.replace('.', '-')} ${hm}`;
return {
title: indexTitle.length === newcontent.length ? indexTitle : `${indexTitle}...`,
description: [istop ? '置顶:' : '', newcontent].filter((str) => !!str).join('<br/>'),
pubDate: new Date(dateStr).toUTCString(),
link: `${baseUrl}${url}`,
};
});
ctx.state.data = {
title: `第一财经 - 直播区`,
description: `第一财经 - 直播区`,
link: `${baseUrl}/brief`,
item,
};
};