From bb820b029ade79e70d1aa2a267453dc017efb04c Mon Sep 17 00:00:00 2001 From: Ethan Shen <42264778+nczitzk@users.noreply.github.com> Date: Mon, 16 Oct 2023 08:21:01 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E6=B5=99=E6=B1=9F?= =?UTF-8?q?=E7=9C=81=E5=85=AC=E5=8A=A1=E5=91=98=E8=80=83=E8=AF=95=E5=BD=95?= =?UTF-8?q?=E7=94=A8=E7=BD=91=20(#13526)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/v2/gov/maintainer.js | 1 + lib/v2/gov/radar.js | 11 ++++ lib/v2/gov/router.js | 1 + lib/v2/gov/zhejiang/gwy.js | 84 +++++++++++++++++++++++++++++++ website/docs/routes/government.md | 32 ++++++++++++ 5 files changed, 129 insertions(+) create mode 100644 lib/v2/gov/zhejiang/gwy.js diff --git a/lib/v2/gov/maintainer.js b/lib/v2/gov/maintainer.js index 0463128bd..1cba1164c 100644 --- a/lib/v2/gov/maintainer.js +++ b/lib/v2/gov/maintainer.js @@ -87,4 +87,5 @@ module.exports = { '/wuhan/sy/whyw': ['nczitzk'], '/xinyi/:path+': ['ShuiHuo'], '/xuzhou/hrss/:category?': ['nczitzk'], + '/zhejiang/gwy/:category?/:column?': ['nczitzk'], }; diff --git a/lib/v2/gov/radar.js b/lib/v2/gov/radar.js index 6a7d62d06..45c5ad95a 100644 --- a/lib/v2/gov/radar.js +++ b/lib/v2/gov/radar.js @@ -1168,4 +1168,15 @@ module.exports = { }, ], }, + 'zjks.gov.cn': { + _name: '浙江省公务员考试录用网', + '.': [ + { + title: '地市专栏', + docs: 'https://docs.rsshub.app/routes/government#zhe-jiang-sheng-gong-wu-yuan-kao-shi-lu-yong-wang', + source: ['/zjgwy/website/init.htm', '/zjgwy/website/queryDetail.htm', '/zjgwy/website/queryMore.htm'], + target: '/gov/zhejiang/gwy', + }, + ], + }, }; diff --git a/lib/v2/gov/router.js b/lib/v2/gov/router.js index 46ceb8588..744b260e1 100644 --- a/lib/v2/gov/router.js +++ b/lib/v2/gov/router.js @@ -78,4 +78,5 @@ module.exports = function (router) { router.get('/wuhan/sy/whyw', require('./wuhan/whyw')); router.get(/xinyi(\/[\w/-]+)?/, require('./xinyi/xinyi')); router.get('/xuzhou/hrss/:category?', require('./xuzhou/hrss')); + router.get('/zhejiang/gwy/:category?/:column?', require('./zhejiang/gwy')); }; diff --git a/lib/v2/gov/zhejiang/gwy.js b/lib/v2/gov/zhejiang/gwy.js new file mode 100644 index 000000000..f6fea226d --- /dev/null +++ b/lib/v2/gov/zhejiang/gwy.js @@ -0,0 +1,84 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const { category, column } = ctx.params; + const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 50; + + const rootUrl = 'http://gwy.zjks.gov.cn'; + const currentUrl = new URL(`zjgwy/website/${category ? 'queryMore' : 'init'}.htm`, rootUrl).href; + const detailUrl = new URL('zjgwy/website/queryDetail.htm', rootUrl).href; + + const { data: response } = await got.post(currentUrl, { + form: { + dsdm: column, + mkxh: category, + oldornew: 'new', + }, + }); + + const $ = cheerio.load(response); + + let items = $('a[onclick^="queryDetail"]') + .slice(0, limit) + .toArray() + .map((item) => { + item = $(item); + + const matches = item.prop('onclick').match(/queryDetail\('?(\d+)'?, '?(\d+)'?\);/); + + return { + title: item.text(), + link: detailUrl, + category: matches[1], + guid: `zjks-${matches[1]}-${matches[2]}`, + pubDate: parseDate(item.parent().next().text()), + tzid: matches[2], + }; + }); + + items = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.guid, async () => { + const { data: detailResponse } = await got.post(detailUrl, { + form: { + mkxh: item.category, + oldornew: 'new', + dsdm: column, + tzid: item.tzid, + }, + }); + + const content = cheerio.load(detailResponse); + + item.description = content('div.ibox-content').last().html(); + item.category = [content('div.ibox-title').last().find('h5').first().text()]; + + const files = content('a.ke-insertfile'); + + if (files.length > 0) { + const file = files.first(); + item.enclosure_url = file.prop('href'); + } + + delete item.tzid; + + return item; + }) + ) + ); + + const columnName = $('button.btn-success').last().text(); + const categoryName = $('table').parent().prev().find('h5').text(); + + ctx.state.data = { + item: items, + title: `${$('title').text()} - ${columnName}${categoryName}`, + link: currentUrl, + description: $('div.title-font2').text(), + subtitle: `${columnName}${categoryName}`, + author: $('div.title-font').text(), + allowEmpty: true, + }; +}; diff --git a/website/docs/routes/government.md b/website/docs/routes/government.md index f740ffc06..ccce5daa8 100644 --- a/website/docs/routes/government.md +++ b/website/docs/routes/government.md @@ -1144,6 +1144,38 @@ Language +## 浙江省公务员考试录用网 {#zhe-jiang-sheng-gong-wu-yuan-kao-shi-lu-yong-wang} + +### 通知 {#zhe-jiang-sheng-gong-wu-yuan-kao-shi-lu-yong-wang-tong-zhi} + + + +| 分类 | id | +| ------------ | --- | +| 重要通知 | 1 | +| 招考公告 | 2 | +| 招考政策 | 3 | +| 面试体检考察 | 4 | +| 录用公示专栏 | 5 | + +| 地市 | id | +| ------------ | ----- | +| 浙江省 | 133 | +| 浙江省杭州市 | 13301 | +| 浙江省宁波市 | 13302 | +| 浙江省温州市 | 13303 | +| 浙江省嘉兴市 | 13304 | +| 浙江省湖州市 | 13305 | +| 浙江省绍兴市 | 13306 | +| 浙江省金华市 | 13307 | +| 浙江省衢州市 | 13308 | +| 浙江省舟山市 | 13309 | +| 浙江省台州市 | 13310 | +| 浙江省丽水市 | 13311 | +| 省级单位 | 13317 | + + + ## 浙江省土地使用权网上交易系统 {#zhe-jiang-sheng-tu-di-shi-yong-quan-wang-shang-jiao-yi-xi-tong} ### 公告信息 {#zhe-jiang-sheng-tu-di-shi-yong-quan-wang-shang-jiao-yi-xi-tong-gong-gao-xin-xi}