feat(route): add 中国经济50人论坛的专家文章页面 (#7273)
* 生成中国经济50人论坛专家文章的RSS * 添加路由 * 修正link url重复斜杠的问题 * refactor: migrate to v2 Co-authored-by: TonyRL <TonyRL@users.noreply.github.com>
This commit is contained in:
parent
f7899272c7
commit
8b8bd685a9
|
|
@ -1934,6 +1934,12 @@ others = 热点新闻 + 滚动新闻
|
|||
|
||||
</Route>
|
||||
|
||||
## 经济 50 人论坛
|
||||
|
||||
### 专家文章
|
||||
|
||||
<Route author="sddiky" example="/50forum" path="/50forum"/>
|
||||
|
||||
## 鲸跃汽车
|
||||
|
||||
### 首页
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/': ['sddiky'],
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'50forum.org.cn': {
|
||||
_name: '经济 50 人论坛',
|
||||
'.': [
|
||||
{
|
||||
title: '专家文章',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#jing-ji-50-ren-lun-tan',
|
||||
source: ['/home/article/index/category/zhuanjia.html', '/'],
|
||||
target: '/50forum',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/', require('./zhuanjia'));
|
||||
};
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'http://www.50forum.org.cn';
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `${rootUrl}/home/article/index/category/zhuanjia.html`,
|
||||
});
|
||||
const data = response.data;
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
const $ = cheerio.load(data);
|
||||
let out = $('div.container div.list_list.mtop10 ul li')
|
||||
.find('a')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
const link = rootUrl + item.attr('href');
|
||||
const reg = /^(.+)\[(.+)\](.+)$/;
|
||||
const keyword = reg.exec(item.text().trim());
|
||||
return {
|
||||
title: keyword[1],
|
||||
author: keyword[2],
|
||||
link,
|
||||
};
|
||||
});
|
||||
|
||||
out = await Promise.all(
|
||||
out.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const result = await got(item.link);
|
||||
|
||||
const $ = cheerio.load(result.data);
|
||||
|
||||
item.description = $('div.list_content').html();
|
||||
item.pubDate = timezone(parseDate($('span#publish_time').text(), 'YYYY-MM-DD HH:mm'), +8);
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
ctx.state.data = {
|
||||
title: `中国经济50人论坛专家文章`,
|
||||
link: 'http://www.50forum.org.cn/home/article/index/category/zhuanjia.html',
|
||||
description: '中国经济50人论坛专家文章',
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue