Add(route): add 上海市职业能力考试院 (#8912)

Co-authored-by: DIYgod <diy.d.god@gmail.com>
This commit is contained in:
Fatpandac 2022-01-22 20:01:20 +08:00 committed by GitHub
parent a0f01e689a
commit 1c6033113f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 65 additions and 0 deletions

View File

@ -212,6 +212,12 @@ pageClass: routes
<Route author="sgqy" example="/go.jp/mofa" path="/go.jp/mofa"/>
## 上海市职业能力考试院
### 考试项目
<Route author="Fatpandac" example="/gov/shanghai/rsj/ksxm" path="/gov/shanghai/rsj/ksxm"/>
## 世界贸易组织
### 争端解决新闻

View File

@ -1,4 +1,5 @@
module.exports = {
'/shanghai/rsj/ksxm': ['Fatpandac'],
'/guangdong/tqyb/tfxtq': ['Fatpandac'],
'/guangdong/tqyb/sncsyjxh': ['Fatpandac'],
};

View File

@ -1,4 +1,15 @@
module.exports = {
'rsj.sh.gov.cn': {
_name: '上海市职业能力考试院',
'.': [
{
title: '考试项目',
docs: 'https://docs.rsshub.app/government.html#shang-hai-shi-zhi-ye-neng-li-kao-shi-yuan-kao-shi-xiang-mu',
source: ['/'],
target: '/gov/shanghai/rsj/ksxm',
},
],
},
'tqyb.com.cn': {
_name: '广州天气',
www: [

View File

@ -1,4 +1,5 @@
module.exports = function (router) {
router.get('/shanghai/rsj/ksxm', require('./shanghai/rsj/ksxm'));
router.get('/guangdong/tqyb/tfxtq', require('./guangdong/tqyb/tfxtq'));
router.get('/guangdong/tqyb/sncsyjxh', require('./guangdong/tqyb/sncsyjxh'));
};

View File

@ -0,0 +1,39 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const iconv = require('iconv-lite');
const { art } = require('@/utils/render');
const path = require('path');
const rootUrl = 'http://www.rsj.sh.gov.cn';
module.exports = async (ctx) => {
const url = `${rootUrl}/ksyzc/wangz/kwaplist_300.jsp`;
const response = await got({
method: 'get',
url,
responseType: 'buffer',
});
const dataHtml = iconv.decode(response.data, 'gbk');
const $ = cheerio.load(dataHtml);
const items = $('kwap')
.map((_, item) => ({
title: $(item).find('kaosxmmc').text(),
link: `http://www.rsj.sh.gov.cn/ksyzc/index801.jsp`,
description: art(path.join(__dirname, './templates/ksxm.art'), {
name: $(item).find('kaosxmmc').text(),
type: $(item).find('kaoslb_dmfy').text(),
date: $(item).find('kaosrq').text(),
registrationDeadline: $(item).find('baomksrq_A300').text(),
}),
guid: `${$(item).find('kaosrq').text()}${$(item).find('kaosxmmc').text()}`,
}))
.get();
ctx.state.data = {
title: '上海市职业能力考试院 - 考试项目',
link: url,
item: items,
};
};

View File

@ -0,0 +1,7 @@
<text>考试项目名称:{{ name }} </text>
<br>
<text>考试类别:{{ type }} </text>
<br>
<text>考试日期:{{ date }} </text>
<br>
<text>报名起止日期:{{ registrationDeadline }} </text>