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`, + })), + }; +};