diff --git a/docs/study.md b/docs/study.md index 1116b3f79..5dfb0a1fb 100644 --- a/docs/study.md +++ b/docs/study.md @@ -127,6 +127,26 @@ pageClass: routes | wsk | 全国外语水平考试 (WSK) | | mets | 医护英语水平考试 (METS) | +## ProcessOn + +### 推荐 + + + +分类 + +| 所有类型 | 流程图 | BPMN | 思维导图 | UI 原型图 | UML | Org 组织结构图 | 网络拓扑图 | 韦恩图 | | +| -------- | ------ | ---- | -------- | --------- | --- | -------------- | ---------- | ------- | ---- | +| | es | flow | bpmn | mind_free | ui | uml | org | network | venn | + +排序 + +| 人气 | 最多人赞 | 最多收藏 | 最多浏览 | 最新发布 | +| ---- | --------- | -------------- | --------- | ----------- | +| | likeCount | favouriteCount | viewCount | publishTime | + + + ## X-MOL 平台 ### 新闻 diff --git a/lib/router.js b/lib/router.js index 39e41c2c6..19198abeb 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3512,6 +3512,9 @@ router.get('/uisdc/news', require('./routes/uisdc/news')); router.get('/uisdc/zt/:title?', require('./routes/uisdc/zt')); router.get('/uisdc/topic/:title?/:sort?', require('./routes/uisdc/topic')); +// ProcessOn +router.get('/processon/popular/:cate?/:sort?', require('./routes/processon/popular')); + // Mathpix router.get('/mathpix/blog', require('./routes/mathpix/blog')); diff --git a/lib/routes/processon/popular.js b/lib/routes/processon/popular.js new file mode 100644 index 000000000..a5890eff2 --- /dev/null +++ b/lib/routes/processon/popular.js @@ -0,0 +1,52 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const cate = ctx.params.cate || ''; + const sort = ctx.params.sort || ''; + + const rootUrl = 'https://www.processon.com'; + const currentUrl = `${rootUrl}/popular/?cate=${cate}&sort=${sort}`; + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + const list = $('a.chart-title') + .slice(0, 10) + .map((_, item) => { + item = $(item); + return { + title: item.text(), + link: `${rootUrl}${item.attr('href')}`, + description: `${item.parent().prev().html()}

${item.parent().find('p').text()}

`, + }; + }) + .get(); + + const items = await Promise.all( + list.map( + async (item) => + await ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + const content = cheerio.load(detailResponse.data); + + item.author = content('a.user_quickinfo').text(); + item.pubDate = content('.chart-pubtime').text().split('发布于 ')[1]; + + return item; + }) + ) + ); + + ctx.state.data = { + title: $('title').text(), + link: currentUrl, + item: items, + }; +};