feat: add 杭州市国家普通话测试网报信息 (#6196)

This commit is contained in:
ChaosTong
2020-11-29 18:45:41 +00:00
committed by GitHub
parent 2eaffacacb
commit 01e2e15cf6
3 changed files with 54 additions and 0 deletions
+6
View File
@@ -396,3 +396,9 @@ pageClass: routes
### 通知公告
<Route author="nczitzk" example="/cpta/notice" path="/cpta/notice" />
## 杭州市国家普通话测试网报信息
### 考试信息
<Route author="ChaosTong" example="/putonghua" path="/putonghua" />
+3
View File
@@ -3510,6 +3510,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'));
// 国家普通话测试 杭州市
router.get('/putonghua', require('./routes/putonghua/hangzhou'));
// 有道云笔记
router.get('/youdao/xueba', require('./routes/youdao/xueba'));
router.get('/youdao/latest', require('./routes/youdao/latest'));
+45
View File
@@ -0,0 +1,45 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const rootUrl = 'http://cltt.51hzks.cn/queryExamInfo';
const response = await got({
method: 'get',
url: rootUrl,
});
const $ = cheerio.load(response.data);
const title = [];
const items = [];
$('.pth_smrtable')
.find('th')
.each((i, e) => {
const titleStr = $(e).text().replace(/\n/g, '').replace(/\t/g, '');
title.push(titleStr);
});
$('.pth_smrtable')
.find('tr')
.slice(1)
.each((i, e) => {
let examInfo = '';
$(e)
.find('td')
.each((i, e) => {
const titleStr = $(e).text().trim().replace(/\n/g, '').replace(/\t/g, '');
examInfo += `${title[i]}: ${titleStr} `;
});
items.push({ title: '近期杭州市普通话测试信息', description: examInfo });
});
if (!(items.count > 0)) {
items.push({ title: '近期杭州市普通话测试信息', description: '近期暂无考试' });
}
ctx.state.data = {
title: `近期杭州市普通话测试网报时间及考试地点公布`,
link: rootUrl,
item: items,
};
};