feat(route): add 阿里研究院资讯 (#12507)
* feat(route): add 阿里研究院资讯 * docs: fix changes
This commit is contained in:
parent
d96bf69373
commit
7b533fff22
|
|
@ -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>
|
||||
|
||||
## 艾莱资讯
|
||||
|
||||
### 世界轨道交通资讯网
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/information/:type?': ['nczitzk'],
|
||||
};
|
||||
|
|
@ -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',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/information/:type?', require('./information'));
|
||||
};
|
||||
Loading…
Reference in New Issue