diff --git a/docs/government.md b/docs/government.md index 65b5029677..3aa08f8c78 100644 --- a/docs/government.md +++ b/docs/government.md @@ -128,6 +128,12 @@ pageClass: routes +### 惠州市人民政府 + +#### 政务公开 + + + ## 国家税务总局 ### 最新文件 diff --git a/lib/v2/gov/huizhou/zwgk/index.js b/lib/v2/gov/huizhou/zwgk/index.js new file mode 100644 index 0000000000..abe5d4afca --- /dev/null +++ b/lib/v2/gov/huizhou/zwgk/index.js @@ -0,0 +1,58 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); + +const rootURL = 'http://www.huizhou.gov.cn'; + +module.exports = async (ctx) => { + const cate = ctx.params.category ?? 'zwyw'; + const url = `${rootURL}/zwgk/hzsz/${cate}`; + + const response = await got(url); + const $ = cheerio.load(response.data); + const title = $('span#navigation').children('a').last().text(); + const list = $('ul.ul_art_row') + .map((_, item) => ({ + title: $(item).find('a').text().trim(), + link: $(item).find('a').attr('href'), + pubDate: timezone(parseDate($(item).find('li.li_art_date').text().trim()), +8), + })) + .get(); + + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got(item.link); + const content = cheerio.load(detailResponse.data); + + try { + item.description = content('div.artContent').html(); + item.author = content('div.info_fbt') + .find('span.ly') + .text() + .match(/来源:(.*)/)[1]; + item.pubDate = timezone( + parseDate( + content('div.info_fbt') + .find('span.time') + .text() + .match(/时间:(.*)/)[1] + ), + +8 + ); + } catch (e) { + item.description = ''; + } + + return item; + }) + ) + ); + + ctx.state.data = { + title: `惠州市人民政府 - ${title}`, + link: url, + item: items, + }; +}; diff --git a/lib/v2/gov/maintainer.js b/lib/v2/gov/maintainer.js index 6387bce05e..3c8b3f0b11 100644 --- a/lib/v2/gov/maintainer.js +++ b/lib/v2/gov/maintainer.js @@ -5,4 +5,5 @@ module.exports = { '/shanghai/rsj/ksxm': ['Fatpandac'], '/guangdong/tqyb/tfxtq': ['Fatpandac'], '/guangdong/tqyb/sncsyjxh': ['Fatpandac'], + '/huizhou/zwgk/:category?': ['Fatpandac'], }; diff --git a/lib/v2/gov/radar.js b/lib/v2/gov/radar.js index 25eda4bfe8..1ffc688132 100644 --- a/lib/v2/gov/radar.js +++ b/lib/v2/gov/radar.js @@ -330,4 +330,39 @@ module.exports = { }, ], }, + 'huizhou.gov.cn': { + _name: '惠州市人民政府', + www: [ + { + title: '政务公开 - 政务要闻', + docs: 'https://docs.rsshub.app/government.html#guang-yan-an-dong-sheng-xing-xian-ren-min-zheng-zheng-fu-hui-zhou-shi-fu-ren-min-zheng-zheng-fu-zheng-zheng-wu-gong-kai', + source: ['/zwgk/hzsz/:category'], + target: (params) => { + if (params.category === 'zwyw') { + return '/gov/huizhou/zwgk/zwyw'; + } + }, + }, + { + title: '政务公开 - 机关动态', + docs: 'https://docs.rsshub.app/government.html#guang-yan-an-dong-sheng-xing-xian-ren-min-zheng-zheng-fu-hui-zhou-shi-fu-ren-min-zheng-zheng-fu-zheng-zheng-wu-gong-kai', + source: ['/zwgk/hzsz/:category'], + target: (params) => { + if (params.category === 'jgdt') { + return '/gov/huizhou/zwgk/jgdt'; + } + }, + }, + { + title: '政务公开 - 县区要闻', + docs: 'https://docs.rsshub.app/government.html#guang-yan-an-dong-sheng-xing-xian-ren-min-zheng-zheng-fu-hui-zhou-shi-fu-ren-min-zheng-zheng-fu-zheng-zheng-wu-gong-kai', + source: ['/zwgk/hzsz/:category'], + target: (params) => { + if (params.category === 'xqyw') { + return '/gov/huizhou/zwgk/xqyw'; + } + }, + }, + ], + }, }; diff --git a/lib/v2/gov/router.js b/lib/v2/gov/router.js index 732d910858..7e6639c267 100644 --- a/lib/v2/gov/router.js +++ b/lib/v2/gov/router.js @@ -6,4 +6,5 @@ module.exports = function (router) { router.get('/shanghai/wsjkw/yqtb', require('./shanghai/wsjkw/yqtb')); router.get('/guangdong/tqyb/tfxtq', require('./guangdong/tqyb/tfxtq')); router.get('/guangdong/tqyb/sncsyjxh', require('./guangdong/tqyb/sncsyjxh')); + router.get('/huizhou/zwgk/:category?', require('./huizhou/zwgk/index')); };