feat: add 中华人民共和国人力资源和社会保障部社保减免 (#6796)

This commit is contained in:
Ethan Shen
2021-01-26 19:53:52 -05:00
committed by GitHub
parent b447455b6a
commit 7218dc80da
3 changed files with 75 additions and 0 deletions
+12
View File
@@ -575,6 +575,18 @@ pageClass: routes
<Route author="MisteryMonster" example="/gov/moa/sjzxfb" path="/gov/moa/sjzxfb"/>
## 中华人民共和国人力资源和社会保障部
### 社保减免
<Route author="ncziztk" example="/gov/mohrss/sbjm" path="/gov/mohrss/sbjm/:category?" :paramsDesc="['分类,见下表']">
| 要点新闻 | 政策文件 | 工作动态 | 媒体报道 | 图片新闻 |
| -------- | -------- | -------- | -------- | -------- |
| ydxw | zcwj | gzdt | mtbd | tpxw |
</Route>
## 中华人民共和国商务部
### 政务公开
+3
View File
@@ -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;
+60
View File
@@ -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,
};
};