feat(route): add 阿里研究院资讯 (#12507)

* feat(route): add 阿里研究院资讯

* docs: fix changes
This commit is contained in:
Ethan Shen 2023-05-14 00:24:48 +08:00 committed by GitHub
parent d96bf69373
commit 7b533fff22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 87 additions and 0 deletions

View File

@ -1545,6 +1545,17 @@ Supported sub-sites:
<Route author="AlexdanerZe TonyRL" example="/zaker/focusread" path="/zaker/focusread" />
## 阿里研究院
### 资讯
<Route author="nczitzk" example="/aliresearch/information" path="/aliresearch/information/:type?" :paramsDesc="['类型,见下表,默认为新闻']">
| 新闻 | 观点 | 案例 |
| ---- | ---- | ---- |
</Route>
## 艾莱资讯
### 世界轨道交通资讯网

View File

@ -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,
};
};

View File

@ -0,0 +1,3 @@
module.exports = {
'/information/:type?': ['nczitzk'],
};

View File

@ -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',
},
],
},
};

View File

@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/information/:type?', require('./information'));
};