From 6a79ccfe7a5354a5e17a157ddcbfd9bfe66b993d Mon Sep 17 00:00:00 2001 From: zidekuls <28500463+zidekuls@users.noreply.github.com> Date: Wed, 18 Mar 2020 10:39:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20add=20=E5=A4=A9=E5=A4=A9=E5=9F=BA?= =?UTF-8?q?=E9=87=91=20(#4249)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/finance.md | 6 ++++++ lib/router.js | 3 +++ lib/routes/eastmoney/user.js | 30 ++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 lib/routes/eastmoney/user.js diff --git a/docs/finance.md b/docs/finance.md index 2640b29abf..7908eca69c 100644 --- a/docs/finance.md +++ b/docs/finance.md @@ -57,3 +57,9 @@ pageClass: routes | announcement | news | research | + +## 天天基金 + +### 用户动态 + + diff --git a/lib/router.js b/lib/router.js index 0bc9b87811..a392ed351c 100644 --- a/lib/router.js +++ b/lib/router.js @@ -429,6 +429,9 @@ router.get('/xueqiu/stock_info/:id/:type?', require('./routes/xueqiu/stock_info' router.get('/xueqiu/snb/:id', require('./routes/xueqiu/snb')); router.get('/xueqiu/hots', require('./routes/xueqiu/hots')); +// 天天基金 +router.get('/eastmoney/user/:uid', require('./routes/eastmoney/user')); + // Greasy Fork router.get('/greasyfork/:language/:domain?', require('./routes/greasyfork/scripts')); diff --git a/lib/routes/eastmoney/user.js b/lib/routes/eastmoney/user.js new file mode 100644 index 0000000000..6398d8c618 --- /dev/null +++ b/lib/routes/eastmoney/user.js @@ -0,0 +1,30 @@ +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + const uid = ctx.params.uid; + const response = await got({ + method: 'get', + headers: { + Accept: '*/*', + Host: 'i.eastmoney.com', + 'Accept-Encoding': 'gzip, deflate, br', + 'Cache-Control': 'no-cache', + }, + url: `https://i.eastmoney.com/api/ta/UserPostList?p=1&ps=20&uid=${uid}`, + }); + + const data = response.data.data.re; + const username = data[0].post_user.user_nickname; + + ctx.state.data = { + title: `天天基金-${username}的主页`, + link: `https://i.eastmoney.com//${uid}`, + description: `${username} 的 动态`, + item: data.map((item) => ({ + title: item.post_title, + description: item.post_content, + pubDate: item.post_display_time, + link: `http://guba.eastmoney.com/news,${item.code_name},${item.post_id}.html`, + })), + }; +};