diff --git a/docs/new-media.md b/docs/new-media.md index 5ac0adbd7..b59256e88 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -1934,6 +1934,12 @@ others = 热点新闻 + 滚动新闻 +## 经济 50 人论坛 + +### 专家文章 + + + ## 鲸跃汽车 ### 首页 diff --git a/lib/v2/50forum/maintainer.js b/lib/v2/50forum/maintainer.js new file mode 100644 index 000000000..9ade13bfb --- /dev/null +++ b/lib/v2/50forum/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/': ['sddiky'], +}; diff --git a/lib/v2/50forum/radar.js b/lib/v2/50forum/radar.js new file mode 100644 index 000000000..1105e86c8 --- /dev/null +++ b/lib/v2/50forum/radar.js @@ -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', + }, + ], + }, +}; diff --git a/lib/v2/50forum/router.js b/lib/v2/50forum/router.js new file mode 100644 index 000000000..9dde308e9 --- /dev/null +++ b/lib/v2/50forum/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/', require('./zhuanjia')); +}; diff --git a/lib/v2/50forum/zhuanjia.js b/lib/v2/50forum/zhuanjia.js new file mode 100644 index 000000000..456e0158d --- /dev/null +++ b/lib/v2/50forum/zhuanjia.js @@ -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, + }; +};