diff --git a/docs/government.md b/docs/government.md index 8c104b2bd..963baa9b6 100644 --- a/docs/government.md +++ b/docs/government.md @@ -725,6 +725,16 @@ pageClass: routes +### 河北省财政厅 + + + +| 财政动态 | 综合新闻 | 通知公告 | +| ---- | ---- | ---- | +| gzdt | zhxw | tzgg | + + + ### 河北省退役军人事务厅 diff --git a/lib/v2/gov/hebei/czt.js b/lib/v2/gov/hebei/czt.js new file mode 100644 index 000000000..d5603de56 --- /dev/null +++ b/lib/v2/gov/hebei/czt.js @@ -0,0 +1,53 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const category = ctx.params.category ?? 'gzdt'; + + const rootUrl = 'http://czt.hebei.gov.cn'; + const currentUrl = `${rootUrl}/xwdt/${category}`; + + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + let items = $('td li a[title]') + .toArray() + .map((item) => { + item = $(item); + + return { + title: item.text(), + link: `${rootUrl}${/^\.\.\/\.\./.test(item.attr('href')) ? item.attr('href').replace(/^\.\.\/\.\./, '') : `/xwdt/${category}${item.attr('href').replace(/^\./, '')}`}`, + }; + }); + + 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.author = content('meta[name="ContentSource"]').attr('content'); + item.pubDate = parseDate(content('meta[name="PubDate"]').attr('content')); + item.description = content('.TRS_Editor, .content').html(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: $('title').text(), + link: currentUrl, + item: items, + }; +}; diff --git a/lib/v2/gov/maintainer.js b/lib/v2/gov/maintainer.js index 00ff01a1d..7645d58fc 100644 --- a/lib/v2/gov/maintainer.js +++ b/lib/v2/gov/maintainer.js @@ -17,6 +17,7 @@ module.exports = { '/anhui/kjt/:path?': ['nczitzk'], '/beijing/kw/:channel': ['Fatpandac'], + '/hebei/czt/xwdt/:category?': ['nczitzk'], '/shenzhen/hrss/szksy/:caty/:page?': ['zlasd'], '/shenzhen/zzb/:caty/:page?': ['zlasd'], '/shanghai/rsj/ksxm': ['Fatpandac'], diff --git a/lib/v2/gov/radar.js b/lib/v2/gov/radar.js index 116cf0090..9bbbb47ff 100644 --- a/lib/v2/gov/radar.js +++ b/lib/v2/gov/radar.js @@ -300,6 +300,41 @@ module.exports = { }, ], }, + 'hebei.gov.cn': { + _name: '河北省人民政府', + czt: [ + { + title: '河北省财政厅 - 财政动态', + docs: 'https://docs.rsshub.app/government.html#he-bei-sheng-cai-zheng-ting-cai-zheng-dong-tai', + source: ['/xwdt/:category'], + target: (params) => { + if (params.category === 'gzdt') { + return '/gov/hebei/czt/xwdt/:category'; + } + }, + }, + { + title: '河北省财政厅 - 综合新闻', + docs: 'https://docs.rsshub.app/government.html#he-bei-sheng-cai-zheng-ting-zong-he-xin-wen', + source: ['/xwdt/:category'], + target: (params) => { + if (params.category === 'zhxw') { + return '/gov/hebei/czt/xwdt/:category'; + } + }, + }, + { + title: '河北省财政厅 - 通知公告', + docs: 'https://docs.rsshub.app/government.html#he-bei-sheng-cai-zheng-ting-tong-zhi-gong-gao', + source: ['/xwdt/:category'], + target: (params) => { + if (params.category === 'tzgg') { + return '/gov/hebei/czt/xwdt/:category'; + } + }, + }, + ], + }, 'homeaffairs.gov.au': { _name: 'Department of Home Affairs', immi: [ diff --git a/lib/v2/gov/router.js b/lib/v2/gov/router.js index e285591b0..853d6c35f 100644 --- a/lib/v2/gov/router.js +++ b/lib/v2/gov/router.js @@ -18,6 +18,7 @@ module.exports = function (router) { // province router.get(/anhui\/kjt\/([\w\d/-]+)?/, require('./anhui/kjt')); router.get('/beijing/kw/:channel', require('./beijing/kw/index')); + router.get('/hebei/czt/xwdt/:category?', require('./hebei/czt')); 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'));