From d720d588d9a349bda5954697c66dc5447fe25266 Mon Sep 17 00:00:00 2001 From: sanmmmm Date: Fri, 26 Jul 2019 11:09:41 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=20=E7=AC=AC=E4=B8=80?= =?UTF-8?q?=E8=B4=A2=E7=BB=8F=20=E7=9B=B4=E6=92=AD=E5=8C=BA=20(#2690)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: DIYgod --- docs/traditional-media.md | 6 ++++++ lib/router.js | 3 +++ lib/routes/yicai/brief.js | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 lib/routes/yicai/brief.js diff --git a/docs/traditional-media.md b/docs/traditional-media.md index 73c4f4118..d77ab8741 100644 --- a/docs/traditional-media.md +++ b/docs/traditional-media.md @@ -124,6 +124,12 @@ Category 列表: +## 第一财经 + +### 直播区 + + + ## 东方网 ### 上海新闻 diff --git a/lib/router.js b/lib/router.js index ef21edb7d..121b971c3 100644 --- a/lib/router.js +++ b/lib/router.js @@ -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')); diff --git a/lib/routes/yicai/brief.js b/lib/routes/yicai/brief.js new file mode 100644 index 000000000..80bf58680 --- /dev/null +++ b/lib/routes/yicai/brief.js @@ -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('
'), + pubDate: new Date(dateStr).toUTCString(), + link: `${baseUrl}${url}`, + }; + }); + + ctx.state.data = { + title: `第一财经 - 直播区`, + description: `第一财经 - 直播区`, + link: `${baseUrl}/brief`, + item, + }; +};