From 4df468d36ad05a4164b2a52d7dce9bf55bc32ad0 Mon Sep 17 00:00:00 2001 From: zlasd Date: Sun, 23 Jan 2022 03:55:58 +0800 Subject: [PATCH] =?UTF-8?q?Add(route):=20add=20=E6=B7=B1=E5=9C=B3=E5=B8=82?= =?UTF-8?q?=E5=A7=94=E7=BB=84=E7=BB=87=E9=83=A8=20&=20=E6=B7=B1=E5=9C=B3?= =?UTF-8?q?=E8=80=83=E8=AF=95=E9=99=A2=20(#8851)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: DIYgod --- docs/government.md | 20 ++++++++++++ lib/v2/gov/maintainer.js | 2 ++ lib/v2/gov/radar.js | 22 +++++++++++++ lib/v2/gov/router.js | 2 ++ lib/v2/gov/shenzhen/hrss/szksy/index.js | 41 +++++++++++++++++++++++++ lib/v2/gov/shenzhen/zzb/index.js | 40 ++++++++++++++++++++++++ 6 files changed, 127 insertions(+) create mode 100644 lib/v2/gov/shenzhen/hrss/szksy/index.js create mode 100644 lib/v2/gov/shenzhen/zzb/index.js diff --git a/docs/government.md b/docs/government.md index 2ea4d0bb9c..0d126c6b60 100644 --- a/docs/government.md +++ b/docs/government.md @@ -96,6 +96,26 @@ pageClass: routes +### 深圳市委组织部 + + + +| 通知公告 | 任前公示 | 政策法规 | 工作动态 | 部门预算决算公开 | 业务表格下载 | +| :------: | :------: | :------: | :------: | :--------------: | :----------: | +| tzgg | rqgs | zcfg | gzdt | xcbd | bgxz | + + + +### 深圳市考试院 + + + +| 通知公告 | 报名信息 | 成绩信息 | 合格标准 | 合格人员公示 | 证书发放信息 | +| :------: | :------: | :------: | :------: | :----------: | :----------: | +| tzgg | bmxx | cjxx | hgbz | hgrygs | zsff | + + + ## 国家税务总局 ### 最新文件 diff --git a/lib/v2/gov/maintainer.js b/lib/v2/gov/maintainer.js index dd4c9fc8d5..7d10f2b15c 100644 --- a/lib/v2/gov/maintainer.js +++ b/lib/v2/gov/maintainer.js @@ -1,4 +1,6 @@ module.exports = { + '/shenzhen/hrss/szksy/:caty/:page?': ['zlasd'], + '/shenzhen/zzb/:caty/:page?': ['zlasd'], '/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 ae5a1f9748..45510255bc 100644 --- a/lib/v2/gov/radar.js +++ b/lib/v2/gov/radar.js @@ -1,4 +1,26 @@ module.exports = { + 'hrss.sz.gov.cn': { + _name: '深圳考试院', + '.': [ + { + title: '公告', + docs: 'https://docs.rsshub.app/government.html#guang-dong-sheng-ren-min-zheng-fu-shen-zhen-shi-wei-zu-zhi-bu', + source: ['/*'], + target: '/gov/shenzhen/hrss/szksy/:caty/:page?', + }, + ], + }, + 'zzb.sz.gov.cn': { + _name: '深圳组工在线', + www: [ + { + title: '公告', + docs: 'https://docs.rsshub.app/government.html#guang-dong-sheng-ren-min-zheng-fu-shen-zhen-shi-kao-shi-yuan', + source: ['/*'], + target: '/gov/shenzhen/zzb/:caty/:page?', + }, + ], + }, 'rsj.sh.gov.cn': { _name: '上海市职业能力考试院', '.': [ diff --git a/lib/v2/gov/router.js b/lib/v2/gov/router.js index 13c404e69a..1c75877faf 100644 --- a/lib/v2/gov/router.js +++ b/lib/v2/gov/router.js @@ -1,4 +1,6 @@ module.exports = function (router) { + router.get('/shenzhen/hrss/szksy/:caty/:page?', require('./shenzhen/hrss/szksy/index')); + router.get('/shenzhen/zzb/:caty/:page?', require('./shenzhen/zzb/index')); 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/shenzhen/hrss/szksy/index.js b/lib/v2/gov/shenzhen/hrss/szksy/index.js new file mode 100644 index 0000000000..f2bf4d4823 --- /dev/null +++ b/lib/v2/gov/shenzhen/hrss/szksy/index.js @@ -0,0 +1,41 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); + +const rootURL = 'http://hrss.sz.gov.cn/'; + +module.exports = async (ctx) => { + const categoryID = ctx.params.caty; + const page = ctx.params.page ?? '1'; + + const pageParam = parseInt(page) > 1 ? `_${page}` : ''; + const pagePath = `/szksy/zwgk/${categoryID}/index${pageParam}.html`; + + const currentURL = new URL(pagePath, rootURL); // do not use deprecated 'url.resolve' + const response = await got({ method: 'get', url: currentURL }); + if (response.statusCode !== 200) { + throw new Error(response.statusMessage); + } + + const $ = cheerio.load(response.data); + const title = $('.zx_rm_tit span').text().trim(); + const list = $('.zx_ml_list ul li') + .slice(1) + .map((_, item) => { + const tag = $(item).find('div.list_name a'); + const tag2 = $(item).find('span:eq(1)'); + return { + title: tag.text().trim(), + link: tag.attr('href'), + pubDate: timezone(parseDate(tag2.text().trim(), 'YYYY/MM/DD'), 0), + }; + }) + .get(); + + ctx.state.data = { + title: '深圳市考试院 - ' + title, + link: currentURL.href, + item: list, + }; +}; diff --git a/lib/v2/gov/shenzhen/zzb/index.js b/lib/v2/gov/shenzhen/zzb/index.js new file mode 100644 index 0000000000..a26b164194 --- /dev/null +++ b/lib/v2/gov/shenzhen/zzb/index.js @@ -0,0 +1,40 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); + +const rootURL = 'http://www.zzb.sz.gov.cn/'; + +module.exports = async (ctx) => { + const categoryID = ctx.params.caty; + const page = ctx.params.page ?? '1'; + + const pageParam = parseInt(page) > 1 ? `_${page}` : ''; + const pagePath = `/${categoryID}/index${pageParam}.html`; + + const currentURL = new URL(pagePath, rootURL); // do not use deprecated 'url.resolve' + const response = await got({ method: 'get', url: currentURL }); + if (response.statusCode !== 200) { + throw new Error(response.statusMessage); + } + + const $ = cheerio.load(response.data); + const title = $('#Title').text().trim(); + const list = $('#List tbody tr td table tbody tr td[width="96%"]') + .map((_, item) => { + const tag = $(item).find('font a'); + const tag2 = $(item).find('font[size="2px"]'); + return { + title: tag.text(), + link: tag.attr('href'), + pubDate: timezone(parseDate(tag2.text().trim(), 'YYYY/MM/DD'), 0), + }; + }) + .get(); + + ctx.state.data = { + title: '深圳组工在线 - ' + title, + link: currentURL.href, + item: list, + }; +};