feat(route): add 上海教育考试院自学考试通知公告 (#7863)

* feat(route): add 上海教育考试院自学考试通知公告

* refactor: migrate to v2

Co-authored-by: oyydd <oyy284688@gmail.com>
Co-authored-by: TonyRL <TonyRL@users.noreply.github.com>
This commit is contained in:
32fsd
2022-02-22 23:36:02 +08:00
committed by GitHub
co-authored by oyydd TonyRL
parent 47bbbedf7a
commit d9ea1729d1
7 changed files with 85 additions and 8 deletions
-7
View File
@@ -747,13 +747,6 @@ type 为 all 时,category 参数不支持 cost 和 free
</Route>
## 上海市教育考试院
### 消息速递
官方网址:<http://www.shmeea.edu.cn>
<Route author="jialinghui" example="/shmeea" path="/shmeea" radar="1" rssbud="1"/>
## 上海证券交易所
### 上市公司信息最新公告披露
+12
View File
@@ -278,6 +278,18 @@ path="/ctfhub/upcoming/:limit?"
</Route>
## 上海市教育考试院
### 消息速递
官方网址:<http://www.shmeea.edu.cn>
<Route author="jialinghui" example="/shmeea" path="/shmeea" radar="1" rssbud="1"/>
### 自学考试通知公告
<Route author="h2ws" example="/shmeea/self-study" path="/shmeea/self-study" radar="1" rssbud="1"/>
## 思维导图社区
### 热门导图
+3
View File
@@ -3605,6 +3605,9 @@ router.get('/esquirehk/tag/:id', lazyloadRouteHandler('./routes/esquirehk/tag'))
// 国家普通话测试 杭州市
router.get('/putonghua', lazyloadRouteHandler('./routes/putonghua/hangzhou'));
// 国家自学考试 上海市 migrated to v2 /shmeea/self-study
// router.get('/self-study/shanghai', require('./routes/self-study/shanghai'));
// 有道云笔记
router.get('/youdao/xueba', lazyloadRouteHandler('./routes/youdao/xueba'));
router.get('/youdao/latest', lazyloadRouteHandler('./routes/youdao/latest'));
+1
View File
@@ -1,3 +1,4 @@
module.exports = {
'/': ['jialinghui'],
'/self-study': ['h2ws'],
};
+6
View File
@@ -8,6 +8,12 @@ module.exports = {
source: ['/'],
target: '/shmeea',
},
{
title: '自学考试通知公告',
docs: 'https://docs.rsshub.app/other.html#shang-hai-shi-jiao-yu-kao-shi-yuan',
source: ['/page/04000/index.html', '/'],
target: '/shmeea/self-study',
},
],
},
};
+2 -1
View File
@@ -1,3 +1,4 @@
module.exports = function (router) {
router.get('', require('./index'));
router.get('/', require('./index'));
router.get('/self-study', require('./self-study'));
};
+61
View File
@@ -0,0 +1,61 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const timezone = require('@/utils/timezone');
async function load_detail(list, cache) {
return await Promise.all(
list.map(async (item) => {
const notice_item = cheerio.load(item);
const href = notice_item('a').attr('href');
const url = 'http://www.shmeea.edu.cn' + href;
if (href[0] !== '/') {
return {
title: notice_item('a').attr('title'),
description: `<a href="${href}" >附件</a>`,
link: href,
};
}
return await cache.tryGet(url, async () => {
const detail_response = await got({
method: 'get',
url,
headers: {
Referer: 'http://www.shmeea.edu.cn/page/04000/index.html',
Host: 'www.shmeea.edu.cn',
},
});
const detail = cheerio.load(detail_response.data);
return {
title: notice_item('a').attr('title'),
description: detail('.Article_content').html(),
link: url,
pubDate: timezone(parseDate(detail('.PBtime').text(), 'YYYY-MM-DD HH:mm:ss'), +8),
};
});
})
);
}
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: 'http://www.shmeea.edu.cn/page/04000/index.html',
headers: {
Host: 'www.shmeea.edu.cn',
},
});
const data = response.data;
const $ = cheerio.load(data);
const list = $('#main > div.container > div > div.span9 > div.page-he > div > ul > li').get();
const detail = await load_detail(list, ctx.cache);
ctx.state.data = {
title: '上海自学考试 - 通知公告',
link: 'http://www.shmeea.edu.cn/page/04000/index.html',
item: detail,
};
};