From 7afd8686f63302cafe6729d372c402ac5d634b24 Mon Sep 17 00:00:00 2001 From: Ethan Shen <42264778+nczitzk@users.noreply.github.com> Date: Tue, 28 Jun 2022 14:36:47 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E5=BE=90=E5=B7=9E?= =?UTF-8?q?=E5=B8=82=E4=BA=BA=E5=8A=9B=E8=B5=84=E6=BA=90=E5=92=8C=E7=A4=BE?= =?UTF-8?q?=E4=BC=9A=E4=BF=9D=E9=9A=9C=E5=B1=80=20(#10048)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(route): add 徐州市人力资源和社会保障局 * fix pubDate --- docs/government.md | 12 +++++++++ lib/v2/gov/maintainer.js | 1 + lib/v2/gov/radar.js | 11 ++++++++ lib/v2/gov/router.js | 1 + lib/v2/gov/xuzhou/hrss.js | 54 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 79 insertions(+) create mode 100644 lib/v2/gov/xuzhou/hrss.js diff --git a/docs/government.md b/docs/government.md index 164c60647e..eeab0f3ad3 100644 --- a/docs/government.md +++ b/docs/government.md @@ -522,6 +522,18 @@ pageClass: routes +## 徐州市人民政府 + +### 徐州市人力资源和社会保障局 + + + +| 通知公告 | 要闻动态 | 县区动态 | 事业招聘 | 企业招聘 | 政声传递 | +| ---- | ------ | ------ | ------ | ------ | ------ | +| | 001001 | 001002 | 001004 | 001005 | 001006 | + + + ## 浙江省土地使用权网上交易系统 ### 公告信息 diff --git a/lib/v2/gov/maintainer.js b/lib/v2/gov/maintainer.js index 1cf372e542..eac595989c 100644 --- a/lib/v2/gov/maintainer.js +++ b/lib/v2/gov/maintainer.js @@ -29,4 +29,5 @@ module.exports = { '/guangdong/tqyb/sncsyjxh': ['Fatpandac'], '/huizhou/zwgk/:category?': ['Fatpandac'], '/sichuan/deyang/govpulicinfo/:countyName': ['zytomorrow'], + '/xuzhou/hrss/:category?': ['nczitzk'], }; diff --git a/lib/v2/gov/radar.js b/lib/v2/gov/radar.js index 4d5f8e323a..146e3882e1 100644 --- a/lib/v2/gov/radar.js +++ b/lib/v2/gov/radar.js @@ -545,4 +545,15 @@ module.exports = { }, ], }, + 'xz.gov.cn': { + _name: '徐州市人民政府', + hrss: [ + { + title: '徐州市人力资源和社会保障局', + docs: 'https://docs.rsshub.app/government.html#xu-zhou-shi-ren-min-zheng-fu-xu-zhou-shi-ren-li-zi-yuan-he-she-hui-bao-zhang-ju', + source: ['/*'], + target: (params, url) => `/gov/xuzhou/hrss${new URL(url).href.match(/\/(\d+)\/subPage.html/)[1] ?? ''}`, + }, + ], + }, }; diff --git a/lib/v2/gov/router.js b/lib/v2/gov/router.js index f14b030f95..28602006f2 100644 --- a/lib/v2/gov/router.js +++ b/lib/v2/gov/router.js @@ -29,4 +29,5 @@ module.exports = function (router) { router.get('/guangdong/tqyb/sncsyjxh', require('./guangdong/tqyb/sncsyjxh')); router.get('/huizhou/zwgk/:category?', require('./huizhou/zwgk/index')); router.get('/sichuan/deyang/govpulicinfo/:countyName', require('./sichuan/deyang/govpulicinfo')); + router.get('/xuzhou/hrss/:category?', require('./xuzhou/hrss')); }; diff --git a/lib/v2/gov/xuzhou/hrss.js b/lib/v2/gov/xuzhou/hrss.js new file mode 100644 index 0000000000..63505d5ef9 --- /dev/null +++ b/lib/v2/gov/xuzhou/hrss.js @@ -0,0 +1,54 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const timezone = require('@/utils/timezone'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const category = ctx.params.category ?? ''; + + const rootUrl = 'http://hrss.xz.gov.cn'; + const currentUrl = `${rootUrl}${category ? `/001/${category}/subPage.html` : ''}`; + + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + let items = (category ? $('.module-items a') : $('.bdl[data-target="1"]').eq(1).find('a')).toArray().map((item) => { + item = $(item); + + const link = item.attr('href'); + + return { + title: item.attr('title'), + link: `${/^http/.test(link) ? '' : rootUrl}${item.attr('href')}`, + }; + }); + + items = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + + const content = cheerio.load(detailResponse.data); + + item.description = content('#Zoom, .mian-cont, .ewb-article-info, #UCAP-CONTENT').html(); + item.pubDate = timezone(parseDate(content('meta[name="PubDate"]').attr('content')), +8); + item.category = content('meta[name="Keywords"]').attr('content')?.split(' '); + + return item; + }) + ) + ); + + ctx.state.data = { + title: `徐州市人力资源和社会保障局 - ${category ? $('.wb-tree-items.current').text() : '通知公告'}`, + link: currentUrl, + item: items, + }; +};