feat(route): add 老虎社区 (#9839)
* feat(route): add 老虎社区 * fix(route): change to use JSON data * docs: fix heading line break * fix(radar): docs url * fix: item.link
This commit is contained in:
parent
f12289fa60
commit
da6a97f7e1
|
|
@ -193,6 +193,13 @@ pageClass: routes
|
|||
## 金十数据
|
||||
|
||||
<Route author="laampui" example="/jinshi/index" path="/jinshi/index" />
|
||||
|
||||
## 老虎社区
|
||||
|
||||
### 个人主页
|
||||
|
||||
<Route author="Fatpandac" example="/laohu8/personal/3527667596890271" path="/laohu8/personal/:id" :paramsDesc="['用户 ID,见网址链接']" rssbud="1" radar="1"/>
|
||||
|
||||
## 麦肯锡中国
|
||||
|
||||
<Route author="laampui" example="/mckinsey/autos" path="/mckinsey/:category?" :paramsDesc="['默认为全部,见下表']">
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/personal/:id': ['Fatpandac'],
|
||||
};
|
||||
|
|
@ -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, '<br><br>'),
|
||||
link: `${rootUrl}/post/${item.id}`,
|
||||
pubDate: parseDate(item.gmtCreate),
|
||||
}))
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `老虎社区 - ${author} 个人社区`,
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -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',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/personal/:id', require('./personal'));
|
||||
};
|
||||
Loading…
Reference in New Issue