diff --git a/docs/journal.md b/docs/journal.md index f477e75dda..2b83b5c259 100644 --- a/docs/journal.md +++ b/docs/journal.md @@ -248,3 +248,15 @@ _仅支持 Science 主刊_ 路由中的参数 id,即用户谷歌学术引用页面 url 中的 id,如 中 user= 后的 mlmE4JMAAAAJ。 + +## 管理世界 + +### 分类 + + + +| 本期要目 | 学术活动 | 通知公告 | +| -------- | -------- | -------- | +| bqym | xshd | tzgg | + + diff --git a/lib/v2/mvm/index.js b/lib/v2/mvm/index.js new file mode 100644 index 0000000000..791d80e9f4 --- /dev/null +++ b/lib/v2/mvm/index.js @@ -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, + }; +}; diff --git a/lib/v2/mvm/maintainer.js b/lib/v2/mvm/maintainer.js new file mode 100644 index 0000000000..81eb78d732 --- /dev/null +++ b/lib/v2/mvm/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:category?': ['nczitzk'], +}; diff --git a/lib/v2/mvm/radar.js b/lib/v2/mvm/radar.js new file mode 100644 index 0000000000..58052e96f6 --- /dev/null +++ b/lib/v2/mvm/radar.js @@ -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?', + }, + ], + }, +}; diff --git a/lib/v2/mvm/router.js b/lib/v2/mvm/router.js new file mode 100644 index 0000000000..cf781366fd --- /dev/null +++ b/lib/v2/mvm/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/:category?', require('./index')); +};