mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat: add mind42 (#6235)
This commit is contained in:
@@ -73,6 +73,31 @@ pageClass: routes
|
||||
|
||||
<Route author="liecn" example="/gradcafe/result/computer" path="/gradcafe/result/:type" :paramsDesc="['按关键词进行搜索,如 computer']"/>
|
||||
|
||||
## Mind42
|
||||
|
||||
### 分类
|
||||
|
||||
<Route author="nczitzk" example="/mind42" path="/mind42/:caty?" :paramsDesc="['分类,见下表,默认为 Overview']">
|
||||
|
||||
| Overview | Popular | All |
|
||||
| -------- | ------- | ------ |
|
||||
| mindmaps | popular | public |
|
||||
|
||||
</Route>
|
||||
|
||||
### 标签
|
||||
|
||||
<Route author="nczitzk" example="/mind42/tag/online" path="/mind42/tag/:id" :paramsDesc="['标签,见下表']">
|
||||
|
||||
| in | online | cleaning | buy | best | services | for | carpet | service | india | company | and | de | mapa | control | malware | online-dating-website-reviews | virus | international-online-dating-sites-review | repair |
|
||||
| -- | ------ | -------- | --- | ---- | -------- | --- | ------ | ------- | ----- | ------- | --- | -- | ---- | ------- | ------- | ----------------------------- | ----- | ---------------------------------------- | ------ |
|
||||
|
||||
</Route>
|
||||
|
||||
### 搜索
|
||||
|
||||
<Route author="nczitzk" example="/mind42/search/online" path="/mind42/search/:keyword" :paramsDesc="['关键字']"/>
|
||||
|
||||
## NEEA 中国教育考试网
|
||||
|
||||
### 国家教育考试
|
||||
|
||||
@@ -3512,6 +3512,11 @@ 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'));
|
||||
|
||||
// Mind42
|
||||
router.get('/mind42/tag/:id', require('./routes/mind42/tag'));
|
||||
router.get('/mind42/search/:keyword', require('./routes/mind42/search'));
|
||||
router.get('/mind42/:caty?', require('./routes/mind42/index'));
|
||||
|
||||
// 幕布网
|
||||
router.get('/mubu/explore/:tagId/:title?', require('./routes/mubu/explore'));
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
const utils = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const currentUrl = ctx.params.caty || 'mindmaps';
|
||||
|
||||
ctx.state.data = await utils(ctx, currentUrl);
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
const utils = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
ctx.state.data = await utils(ctx, `search?q=${ctx.params.keyword}`);
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
const utils = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
ctx.state.data = await utils(ctx, `tag/${ctx.params.id}`);
|
||||
};
|
||||
@@ -0,0 +1,48 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx, currentUrl) => {
|
||||
const rootUrl = `https://mind42.com`;
|
||||
currentUrl = `${rootUrl}/${currentUrl}`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.title a.title')
|
||||
.slice(0, 10)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
link: `${rootUrl}${item.attr('href')}`,
|
||||
};
|
||||
})
|
||||
.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.title = content('h1 a[name="info"]').text();
|
||||
item.author = content('.creator').text().trim().replace('by', '');
|
||||
item.description = `<img src="/api/ajax/mindmapThumbnail?mindmapId=${item.link.split('/public/')[1]}&size=gallery"><p>${content('.description').text()}</p>`;
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
return {
|
||||
title: $('title').text().split(' - ')[0],
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user