diff --git a/lib/v2/gov/maintainer.js b/lib/v2/gov/maintainer.js index 1cba1164c..80f7d5055 100644 --- a/lib/v2/gov/maintainer.js +++ b/lib/v2/gov/maintainer.js @@ -20,7 +20,8 @@ module.exports = { '/fmprc/:category?': ['nicolaszf', 'nczitzk'], '/immiau/news': ['liu233w'], '/jinan/healthcommission/medical_exam_notice': ['tzjyxb'], - '/mee/ywdt?': ['liuxsdev'], + '/mee/ywdt/:category?': ['liuxsdev'], + '/mem/gk/sgcc/:category?': ['nczitzk'], '/mfa/wjdt/:category?': ['nczitzk'], '/miit/wjfb/:ministry': ['Fatpandac'], '/miit/yjzj': ['Fatpandac'], diff --git a/lib/v2/gov/mem/sgcc.js b/lib/v2/gov/mem/sgcc.js new file mode 100644 index 000000000..e19d0d78e --- /dev/null +++ b/lib/v2/gov/mem/sgcc.js @@ -0,0 +1,64 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const { category = 'sggpdbqk' } = ctx.params; + const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 30; + + const rootUrl = 'https://www.mem.gov.cn'; + const currentUrl = new URL(`gk/sgcc/${category}`, rootUrl).href; + + const { data: response } = await got(currentUrl); + + const $ = cheerio.load(response); + + let items = $('table.center_main02') + .find('a[title]') + .slice(0, limit) + .toArray() + .map((item) => { + item = $(item); + + const regExp = new RegExp(`\\/sgcc\\/${category}\\/\\.\\.\\.`); + const link = new URL(`${category}/${item.prop('href').replace(/\.\//, '')}`, currentUrl).href.replace(regExp, ''); + + return { + title: item.contents().first().text(), + link, + pubDate: parseDate(item.find('span').text()), + enclosure_url: link, + enclosure_type: `application/${link.split(/\./).pop()}`, + }; + }); + + items = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + if (item.link.endsWith('html')) { + const { data: detailResponse } = await got(item.link); + + const content = cheerio.load(detailResponse); + + item.description = content('#content').html(); + } + return item; + }) + ) + ); + + const icon = new URL($('link[rel="shortcut icon"]').prop('href'), rootUrl).href; + + ctx.state.data = { + item: items, + title: $('title').text(), + link: currentUrl, + description: $('meta[name="ColumnDescription"]').prop('content'), + language: 'zh', + image: new URL($('#imag').prop('src'), rootUrl).href, + icon, + logo: icon, + subtitle: $('meta[name="ColumnName"]').prop('content'), + author: $('meta[name="SiteName"]').prop('content'), + }; +}; diff --git a/lib/v2/gov/radar.js b/lib/v2/gov/radar.js index 45c5ad95a..6f83e47cc 100644 --- a/lib/v2/gov/radar.js +++ b/lib/v2/gov/radar.js @@ -703,6 +703,17 @@ module.exports = { }, ], }, + 'mem.gov.cn': { + _name: '应急管理部', + www: [ + { + title: '事故及灾害查处', + docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-ying-ji-guan-li-bu', + source: ['/gk/sgcc/:category'], + target: '/gov/mem/gk/sgcc/:category', + }, + ], + }, 'mfa.gov.cn': { _name: '中华人民共和国外交部', www: [ diff --git a/lib/v2/gov/router.js b/lib/v2/gov/router.js index 744b260e1..d084b01c7 100644 --- a/lib/v2/gov/router.js +++ b/lib/v2/gov/router.js @@ -13,6 +13,7 @@ module.exports = function (router) { router.get('/immiau/news', require('./immiau/news')); router.get('/jinan/healthcommission/medical_exam_notice', require('./jinan/healthcommission/medical_exam_notice')); router.get('/mee/ywdt/:category?', require('./mee/ywdt')); + router.get('/mem/gk/sgcc/:category?', require('./mem/sgcc')); router.get('/mfa/wjdt/:category?', require('./mfa/wjdt')); router.get('/miit/wjfb/:ministry', require('./miit/wjfb')); router.get('/miit/yjzj', require('./miit/yjzj')); diff --git a/website/docs/routes/government.md b/website/docs/routes/government.md index efdd5ce48..10c1d1fea 100644 --- a/website/docs/routes/government.md +++ b/website/docs/routes/government.md @@ -1753,6 +1753,18 @@ Language +## 中华人民共和国应急管理部 {#zhong-hua-ren-min-gong-he-guo-ying-ji-guan-li-bu} + +### 事故及灾害查处 {#zhong-hua-ren-min-gong-he-guo-ying-ji-guan-li-bu-shi-gu-ji-zai-hai-cha-chu} + + + +| 挂牌督办 | 调查报告 | +| -------- | ---------- | +| sggpdbqk | tbzdsgdcbg | + + + ## 中华人民共和国住房和城乡建设部 {#zhong-hua-ren-min-gong-he-guo-zhu-fang-he-cheng-xiang-jian-she-bu} ### 政策发布 {#zhong-hua-ren-min-gong-he-guo-zhu-fang-he-cheng-xiang-jian-she-bu-zheng-ce-fa-bu}