diff --git a/lib/v2/shmeea/index.js b/lib/v2/shmeea/index.js
index 14067fd34..6fc1c22f3 100644
--- a/lib/v2/shmeea/index.js
+++ b/lib/v2/shmeea/index.js
@@ -1,44 +1,53 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
+const timezone = require('@/utils/timezone');
+const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
- const baseURL = 'http://www.shmeea.edu.cn';
- const rootUrl = baseURL + '/page/08000/index.html';
- const response = await got({
- method: 'get',
- url: rootUrl,
- });
+ const id = ctx.params.id ?? '08000';
+ const baseURL = 'https://www.shmeea.edu.cn';
+ const link = `${baseURL}/page/${id}/index.html`;
- const data = response.data;
+ const response = await got(link);
+ const $ = cheerio.load(response.data);
- const $ = cheerio.load(data);
+ const title = `上海市教育考试院-${$('#main .pageh4-tit').text().trim()}`;
- const list = $('#main .pageList li');
+ const list = $('#main .pageList li')
+ .toArray()
+ .map((item) => {
+ item = $(item);
+ return {
+ title: item.find('a').attr('title') || item.find('a').text(),
+ link: new URL(item.find('a').attr('href'), baseURL).href,
+ pubDate: parseDate(item.find('.listTime').text().trim(), 'YYYY-MM-DD'),
+ };
+ });
const items = await Promise.all(
- list.map(async (i, item) => {
- item = $(item);
- const link = baseURL + item.find('a').attr('href');
- const description = await ctx.cache.tryGet(link, async () => {
- const result = await got.get(link);
+ list.map((item) =>
+ ctx.cache.tryGet(item.link, async () => {
+ if (!item.link.endsWith('.html') || new URL(item.link).hostname !== new URL(baseURL).hostname) {
+ return item;
+ }
+ const result = await got(item.link);
const $ = cheerio.load(result.data);
- return $('#ivs_content').html();
- });
- return {
- title: item.find('a').text(),
- pubDate: new Date(item.find('.listTime').text()),
- link,
- description,
- };
- })
+ const description = $('#ivs_content').html();
+ const pbTimeText = $('#ivs_title .PBtime').text().trim();
+
+ item.description = description;
+ item.pubDate = pbTimeText ? timezone(parseDate(pbTimeText, 'YYYY-MM-DD HH:mm:ss'), +8) : item.pubDate;
+
+ return item;
+ })
+ )
);
ctx.state.data = {
- title: '上海市教育考试院',
- description: '消息速递',
- link: baseURL,
+ title,
+ link,
item: items,
};
};
diff --git a/lib/v2/shmeea/maintainer.js b/lib/v2/shmeea/maintainer.js
index 000328f18..091353e53 100644
--- a/lib/v2/shmeea/maintainer.js
+++ b/lib/v2/shmeea/maintainer.js
@@ -1,4 +1,4 @@
module.exports = {
- '/': ['jialinghui'],
+ '/:id?': ['jialinghui', 'Misaka13514'],
'/self-study': ['h2ws'],
};
diff --git a/lib/v2/shmeea/radar.js b/lib/v2/shmeea/radar.js
index 7f84a7b93..010c259f6 100644
--- a/lib/v2/shmeea/radar.js
+++ b/lib/v2/shmeea/radar.js
@@ -3,14 +3,17 @@ module.exports = {
_name: '上海市教育考试院',
www: [
{
- title: '消息速递',
- docs: 'https://docs.rsshub.app/routes/other#shang-hai-shi-jiao-yu-kao-shi-yuan',
- source: ['/'],
- target: '/shmeea',
+ title: '消息',
+ docs: 'https://docs.rsshub.app/routes/study#shang-hai-shi-jiao-yu-kao-shi-yuan',
+ source: ['/page/:id?/index.html'],
+ target: (params, url, document) => {
+ const li = document.querySelector('#main .pageList li');
+ return li ? '/shmeea/:id?' : '';
+ },
},
{
title: '自学考试通知公告',
- docs: 'https://docs.rsshub.app/routes/other#shang-hai-shi-jiao-yu-kao-shi-yuan',
+ docs: 'https://docs.rsshub.app/routes/study#shang-hai-shi-jiao-yu-kao-shi-yuan',
source: ['/page/04000/index.html', '/'],
target: '/shmeea/self-study',
},
diff --git a/lib/v2/shmeea/router.js b/lib/v2/shmeea/router.js
index b864ea159..2493022da 100644
--- a/lib/v2/shmeea/router.js
+++ b/lib/v2/shmeea/router.js
@@ -1,4 +1,4 @@
module.exports = function (router) {
- router.get('/', require('./index'));
router.get('/self-study', require('./self-study'));
+ router.get('/:id?', require('./index'));
};
diff --git a/website/docs/routes/study.mdx b/website/docs/routes/study.mdx
index 79dc2ebd2..587ae3e68 100644
--- a/website/docs/routes/study.mdx
+++ b/website/docs/routes/study.mdx
@@ -335,11 +335,19 @@
## 上海市教育考试院 {#shang-hai-shi-jiao-yu-kao-shi-yuan}
-### 消息速递 {#shang-hai-shi-jiao-yu-kao-shi-yuan-xiao-xi-su-di}
+官方网址:[https://www.shmeea.edu.cn](https://www.shmeea.edu.cn)
-官方网址:[http://www.shmeea.edu.cn](http://www.shmeea.edu.cn)
+### 消息 {#shang-hai-shi-jiao-yu-kao-shi-yuan-xiao-xi}
-
+
+ :::tip
+ 例如:消息速递的网址为 `https://www.shmeea.edu.cn/page/08000/index.html`,则页面 ID 为 `08000`。
+ :::
+
+ :::warning
+ 暂不支持大类分类和[院内动态](https://www.shmeea.edu.cn/page/19000/index.html)
+ :::
+
### 自学考试通知公告 {#shang-hai-shi-jiao-yu-kao-shi-yuan-zi-xue-kao-shi-tong-zhi-gong-gao}