diff --git a/docs/government.md b/docs/government.md index 30fd1c689f..edd5a9edbd 100644 --- a/docs/government.md +++ b/docs/government.md @@ -212,6 +212,12 @@ pageClass: routes +## 上海市职业能力考试院 + +### 考试项目 + + + ## 世界贸易组织 ### 争端解决新闻 diff --git a/lib/v2/gov/maintainer.js b/lib/v2/gov/maintainer.js index a1d45dc4d5..dd4c9fc8d5 100644 --- a/lib/v2/gov/maintainer.js +++ b/lib/v2/gov/maintainer.js @@ -1,4 +1,5 @@ module.exports = { + '/shanghai/rsj/ksxm': ['Fatpandac'], '/guangdong/tqyb/tfxtq': ['Fatpandac'], '/guangdong/tqyb/sncsyjxh': ['Fatpandac'], }; diff --git a/lib/v2/gov/radar.js b/lib/v2/gov/radar.js index 27b4a51715..ae5a1f9748 100644 --- a/lib/v2/gov/radar.js +++ b/lib/v2/gov/radar.js @@ -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: [ diff --git a/lib/v2/gov/router.js b/lib/v2/gov/router.js index bf10a4ead2..13c404e69a 100644 --- a/lib/v2/gov/router.js +++ b/lib/v2/gov/router.js @@ -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')); }; diff --git a/lib/v2/gov/shanghai/rsj/ksxm.js b/lib/v2/gov/shanghai/rsj/ksxm.js new file mode 100644 index 0000000000..726467592b --- /dev/null +++ b/lib/v2/gov/shanghai/rsj/ksxm.js @@ -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, + }; +}; diff --git a/lib/v2/gov/shanghai/rsj/templates/ksxm.art b/lib/v2/gov/shanghai/rsj/templates/ksxm.art new file mode 100644 index 0000000000..b6f06dc36a --- /dev/null +++ b/lib/v2/gov/shanghai/rsj/templates/ksxm.art @@ -0,0 +1,7 @@ +考试项目名称:{{ name }} +
+考试类别:{{ type }} +
+考试日期:{{ date }} +
+报名起止日期:{{ registrationDeadline }}