diff --git a/docs/new-media.md b/docs/new-media.md index 4ec2f62bd..a2891688d 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -1545,6 +1545,17 @@ Supported sub-sites: +## 阿里研究院 + +### 资讯 + + + +| 新闻 | 观点 | 案例 | +| ---- | ---- | ---- | + + + ## 艾莱资讯 ### 世界轨道交通资讯网 diff --git a/lib/v2/aliresearch/information.js b/lib/v2/aliresearch/information.js new file mode 100644 index 000000000..38470eff4 --- /dev/null +++ b/lib/v2/aliresearch/information.js @@ -0,0 +1,57 @@ +const got = require('@/utils/got'); +const timezone = require('@/utils/timezone'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const type = ctx.params.type ?? '新闻'; + const limit = ctx.query.limit ? parseInt(ctx.query.limit) : 50; + + const rootUrl = 'http://www.aliresearch.com'; + const currentUrl = `${rootUrl}/cn/information`; + const apiUrl = `${rootUrl}/ch/listArticle`; + + const response = await got({ + method: 'post', + url: apiUrl, + json: { + pageNo: 1, + pageSize: 10, + type, + }, + }); + + let items = response.data.data.slice(0, limit).map((item) => ({ + title: item.articleCode, + author: item.author, + pubDate: timezone(parseDate(item.gmtCreated), +8), + link: `${rootUrl}/ch/information/informationdetails?articleCode=${item.articleCode}`, + })); + + items = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'post', + url: `${rootUrl}/ch/getArticle`, + json: { + articleCode: item.title, + }, + }); + + const data = detailResponse.data.data; + + item.title = data.title; + item.description = data.content; + item.category = data.special.split(','); + + return item; + }) + ) + ); + + ctx.state.data = { + title: `阿里研究院 - ${type}`, + link: currentUrl, + item: items, + }; +}; diff --git a/lib/v2/aliresearch/maintainer.js b/lib/v2/aliresearch/maintainer.js new file mode 100644 index 000000000..5dc189006 --- /dev/null +++ b/lib/v2/aliresearch/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/information/:type?': ['nczitzk'], +}; diff --git a/lib/v2/aliresearch/radar.js b/lib/v2/aliresearch/radar.js new file mode 100644 index 000000000..ed9969de6 --- /dev/null +++ b/lib/v2/aliresearch/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'aliresearch.com': { + _name: '阿里研究院', + '.': [ + { + title: '资讯', + docs: 'https://docs.rsshub.app/new-media.html#a-li-yan-jiu-yuan', + source: ['/cn/information', '/'], + target: '/aliresearch/information', + }, + ], + }, +}; diff --git a/lib/v2/aliresearch/router.js b/lib/v2/aliresearch/router.js new file mode 100644 index 000000000..ab438d810 --- /dev/null +++ b/lib/v2/aliresearch/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/information/:type?', require('./information')); +};