Skip to content

Commit

Permalink
feat(route): add caixin yxnews 财新一线财经消息 (DIYgod#7211)
Browse files Browse the repository at this point in the history
  • Loading branch information
boypt authored May 25, 2021
1 parent 1b287aa commit af5f979
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/traditional-media.md
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,10 @@ Category 列表:

</Route>

### 财新一线

<Route author="boypt" example="/caixin/yxnews" path="/caixin/yxnews"/>

## 第一财经

### 直播区
Expand Down
2 changes: 2 additions & 0 deletions lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
30 changes: 30 additions & 0 deletions lib/routes/caixin/yxnews.js
Original file line number Diff line number Diff line change
@@ -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,
};
};

0 comments on commit af5f979

Please sign in to comment.