From af5f97904ab718655b4e42dc00bd5385bf55c7be Mon Sep 17 00:00:00 2001 From: Preston <1033514+boypt@users.noreply.github.com> Date: Tue, 25 May 2021 21:26:08 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20caixin=20yxnews=20?= =?UTF-8?q?=E8=B4=A2=E6=96=B0=E4=B8=80=E7=BA=BF=E8=B4=A2=E7=BB=8F=E6=B6=88?= =?UTF-8?q?=E6=81=AF=20(#7211)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/traditional-media.md | 4 ++++ lib/router.js | 2 ++ lib/routes/caixin/yxnews.js | 30 ++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 lib/routes/caixin/yxnews.js diff --git a/docs/traditional-media.md b/docs/traditional-media.md index acd2283f28659f..330d12fcb82b92 100644 --- a/docs/traditional-media.md +++ b/docs/traditional-media.md @@ -385,6 +385,10 @@ Category 列表: +### 财新一线 + + + ## 第一财经 ### 直播区 diff --git a/lib/router.js b/lib/router.js index b17bec9bce1b08..5c591ef45f7009 100644 --- a/lib/router.js +++ b/lib/router.js @@ -395,6 +395,8 @@ router.get('/caixin/blog/:column', require('./routes/caixin/blog')); router.get('/caixin/:column/:category', require('./routes/caixin/category')); // 财新首页 router.get('/caixin/article', require('./routes/caixin/article')); +// 财新一线 +router.get('/caixin/yxnews', require('./routes/caixin/yxnews')); // 草榴社区 router.get('/t66y/post/:tid', require('./routes/t66y/post')); diff --git a/lib/routes/caixin/yxnews.js b/lib/routes/caixin/yxnews.js new file mode 100644 index 00000000000000..abba097353c7cc --- /dev/null +++ b/lib/routes/caixin/yxnews.js @@ -0,0 +1,30 @@ +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + const response = await got({ + method: 'get', + url: 'http://k.caixin.com/app/v1/list?productIdList=8,28&uid=&unit=1&name=&code=&deviceType=&device=&userTag=&p=1&c=20', + headers: { + Referer: `http://k.caixin.com/web/`, + Host: 'k.caixin.com', + }, + }); + + const data = response.data.data.list; + const items = await Promise.all( + data.map(async (item) => ({ + title: item.title, + description: item.text, + link: `http://k.caixin.com/web/detail_${item.oneline_news_code}`, + pubDate: new Date(item.ts), + author: '财新一线', + })) + ); + + ctx.state.data = { + title: `财新网 - 财新一线新闻`, + link: `http://k.caixin.com/`, + description: `财新网 - 财新一线新闻`, + item: items, + }; +};