diff --git a/docs/finance.md b/docs/finance.md index 4b3aecf3f..3bfa32667 100644 --- a/docs/finance.md +++ b/docs/finance.md @@ -193,6 +193,13 @@ pageClass: routes ## 金十数据 + +## 老虎社区 + +### 个人主页 + + + ## 麦肯锡中国 diff --git a/lib/v2/laohu8/maintainer.js b/lib/v2/laohu8/maintainer.js new file mode 100644 index 000000000..e2166a81c --- /dev/null +++ b/lib/v2/laohu8/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/personal/:id': ['Fatpandac'], +}; diff --git a/lib/v2/laohu8/personal.js b/lib/v2/laohu8/personal.js new file mode 100644 index 000000000..178b91b8f --- /dev/null +++ b/lib/v2/laohu8/personal.js @@ -0,0 +1,32 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +const rootUrl = 'https://www.laohu8.com'; + +module.exports = async (ctx) => { + const id = ctx.params.id; + const url = `${rootUrl}/personal/${id}`; + + const response = await got(url); + const $ = cheerio.load(response.data); + const author = $('h2.personal-name').text(); + const data = JSON.parse($('#__APP_DATA__').text()).tweetList; + + const items = await Promise.all( + data.map((item) => + ctx.cache.tryGet(item.link, () => ({ + title: item.title, + description: String(item.htmlText).replace(/\n/g, '

'), + link: `${rootUrl}/post/${item.id}`, + pubDate: parseDate(item.gmtCreate), + })) + ) + ); + + ctx.state.data = { + title: `老虎社区 - ${author} 个人社区`, + link: url, + item: items, + }; +}; diff --git a/lib/v2/laohu8/radar.js b/lib/v2/laohu8/radar.js new file mode 100644 index 000000000..777bc92c8 --- /dev/null +++ b/lib/v2/laohu8/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'laohu8.com': { + _name: '老虎社区', + '.': [ + { + title: '个人主页', + docs: 'https://docs.rsshub.app/finance.html#lao-hu-she-qu', + source: '/personal/:id', + target: '/laohu8/personal/:id', + }, + ], + }, +}; diff --git a/lib/v2/laohu8/router.js b/lib/v2/laohu8/router.js new file mode 100644 index 000000000..347dc65d7 --- /dev/null +++ b/lib/v2/laohu8/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/personal/:id', require('./personal')); +};