mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-21 12:49:53 +08:00
feat(route): add 管理世界 (#8385)
This commit is contained in:
@@ -248,3 +248,15 @@ _仅支持 Science 主刊_
|
||||
路由中的参数 id,即用户谷歌学术引用页面 url 中的 id,如 <https://scholar.google.com/citations?hl=zh-CN&user=mlmE4JMAAAAJ> 中 user= 后的 mlmE4JMAAAAJ。
|
||||
|
||||
</Route>
|
||||
|
||||
## 管理世界
|
||||
|
||||
### 分类
|
||||
|
||||
<Route author="nczitzk" example="/mvm" path="/mvm/:category?" :paramsDesc="['分类,见下表,默认为本期要目']">
|
||||
|
||||
| 本期要目 | 学术活动 | 通知公告 |
|
||||
| -------- | -------- | -------- |
|
||||
| bqym | xshd | tzgg |
|
||||
|
||||
</Route>
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category ?? 'bqym';
|
||||
|
||||
const rootUrl = 'http://www.mwm.net.cn';
|
||||
const currentUrl = `${rootUrl}/web/${category === 'bqym' ? `bqym?pagesize=${ctx.query.limit ?? 100}` : category}`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
$('.n_date').remove();
|
||||
|
||||
const list = $('.n_title, .con1_text')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
title: item.text(),
|
||||
link: `${rootUrl}${item.attr('href')}`,
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.description = content('.mrt20').html();
|
||||
item.author = content('.mrl20').text().trim().replace(/作者:/, '');
|
||||
item.pubDate = parseDate(content('.date').eq(0).text(), 'YYYY年MM月DD日');
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/:category?': ['nczitzk'],
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'mwm.net.cn': {
|
||||
_name: '管理世界',
|
||||
'.': [
|
||||
{
|
||||
title: '分类',
|
||||
docs: 'https://docs.rsshub.app/journal.html#guan-li-shi-jie-fen-lei',
|
||||
source: ['/web/:category', '/'],
|
||||
target: '/mvm/:category?',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/:category?', require('./index'));
|
||||
};
|
||||
Reference in New Issue
Block a user