diff --git a/docs/government.md b/docs/government.md index 9292fa0dcc..6482a2a0d2 100644 --- a/docs/government.md +++ b/docs/government.md @@ -575,6 +575,18 @@ pageClass: routes +## 中华人民共和国人力资源和社会保障部 + +### 社保减免 + + + +| 要点新闻 | 政策文件 | 工作动态 | 媒体报道 | 图片新闻 | +| -------- | -------- | -------- | -------- | -------- | +| ydxw | zcwj | gzdt | mtbd | tpxw | + + + ## 中华人民共和国商务部 ### 政务公开 diff --git a/lib/router.js b/lib/router.js index 8eb98ff1fd..442f77ad8c 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3899,4 +3899,7 @@ router.get('/wtu/:type', require('./routes/universities/wtu')); // 中国庭审公开网 router.get('/tingshen', require('./routes/tingshen/tingshen')); +// 中华人民共和国人力资源和社会保障部 +router.get('/gov/mohrss/sbjm/:category?', require('./routes/gov/mohrss/sbjm')); + module.exports = router; diff --git a/lib/routes/gov/mohrss/sbjm.js b/lib/routes/gov/mohrss/sbjm.js new file mode 100644 index 0000000000..aaca031193 --- /dev/null +++ b/lib/routes/gov/mohrss/sbjm.js @@ -0,0 +1,60 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const category = ctx.params.category || 'ydxw'; + + const rootUrl = 'http://www.mohrss.gov.cn'; + const currentUrl = `${rootUrl}/SYrlzyhshbzb/rdzt/jfjf/${category}`; + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + const list = $('.rsb_jfjf_cont2 ul li a') + .slice(0, 15) + .map((_, item) => { + item = $(item); + let link = item.attr('href'); + if (link.indexOf('../../../') >= 0) { + link = `${rootUrl}/SYrlzyhshbzb/${link.replace('../../../', '')}`; + } else if (link.indexOf('./') >= 0) { + link = `${currentUrl}/${link.replace('./', '')}`; + } + return { + title: item.text(), + link, + }; + }) + .get(); + + const items = await Promise.all( + list.map( + async (item) => + await ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + const content = cheerio.load(detailResponse.data); + + item.description = content('#insMainConTxt').html() || content('.TRS_Editor').html() || content('#UCAP-CONTENT').html() || content('.weixinBox').html(); + item.pubDate = new Date( + content('meta[name="PubDate"]').attr('content') || + content('meta[name="publishdate"]').attr('content') || + (content('meta[name="firstpublishedtime"]').attr('content') ? content('meta[name="others"]').attr('content').replace('页面生成时间 ', '') : '') + ).toUTCString(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: $('title').text(), + link: currentUrl, + item: items, + }; +};