feat(route): add 徐州市人力资源和社会保障局 (#10048)

* feat(route): add 徐州市人力资源和社会保障局

* fix pubDate
This commit is contained in:
Ethan Shen
2022-06-27 19:36:47 -11:00
committed by GitHub
parent 0dcea078ee
commit 7afd8686f6
5 changed files with 79 additions and 0 deletions
+12
View File
@@ -522,6 +522,18 @@ pageClass: routes
</Route>
## 徐州市人民政府
### 徐州市人力资源和社会保障局
<Route author="nczitzk" example="/gov/xuzhou/hrss" path="/gov/xuzhou/hrss/:category?" :paramsDesc="['分类,见下表,默认为通知公告']">
| 通知公告 | 要闻动态 | 县区动态 | 事业招聘 | 企业招聘 | 政声传递 |
| ---- | ------ | ------ | ------ | ------ | ------ |
| | 001001 | 001002 | 001004 | 001005 | 001006 |
</Route>
## 浙江省土地使用权网上交易系统
### 公告信息
+1
View File
@@ -29,4 +29,5 @@ module.exports = {
'/guangdong/tqyb/sncsyjxh': ['Fatpandac'],
'/huizhou/zwgk/:category?': ['Fatpandac'],
'/sichuan/deyang/govpulicinfo/:countyName': ['zytomorrow'],
'/xuzhou/hrss/:category?': ['nczitzk'],
};
+11
View File
@@ -545,4 +545,15 @@ module.exports = {
},
],
},
'xz.gov.cn': {
_name: '徐州市人民政府',
hrss: [
{
title: '徐州市人力资源和社会保障局',
docs: 'https://docs.rsshub.app/government.html#xu-zhou-shi-ren-min-zheng-fu-xu-zhou-shi-ren-li-zi-yuan-he-she-hui-bao-zhang-ju',
source: ['/*'],
target: (params, url) => `/gov/xuzhou/hrss${new URL(url).href.match(/\/(\d+)\/subPage.html/)[1] ?? ''}`,
},
],
},
};
+1
View File
@@ -29,4 +29,5 @@ module.exports = function (router) {
router.get('/guangdong/tqyb/sncsyjxh', require('./guangdong/tqyb/sncsyjxh'));
router.get('/huizhou/zwgk/:category?', require('./huizhou/zwgk/index'));
router.get('/sichuan/deyang/govpulicinfo/:countyName', require('./sichuan/deyang/govpulicinfo'));
router.get('/xuzhou/hrss/:category?', require('./xuzhou/hrss'));
};
+54
View File
@@ -0,0 +1,54 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const timezone = require('@/utils/timezone');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const category = ctx.params.category ?? '';
const rootUrl = 'http://hrss.xz.gov.cn';
const currentUrl = `${rootUrl}${category ? `/001/${category}/subPage.html` : ''}`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
let items = (category ? $('.module-items a') : $('.bdl[data-target="1"]').eq(1).find('a')).toArray().map((item) => {
item = $(item);
const link = item.attr('href');
return {
title: item.attr('title'),
link: `${/^http/.test(link) ? '' : rootUrl}${item.attr('href')}`,
};
});
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.description = content('#Zoom, .mian-cont, .ewb-article-info, #UCAP-CONTENT').html();
item.pubDate = timezone(parseDate(content('meta[name="PubDate"]').attr('content')), +8);
item.category = content('meta[name="Keywords"]').attr('content')?.split(' ');
return item;
})
)
);
ctx.state.data = {
title: `徐州市人力资源和社会保障局 - ${category ? $('.wb-tree-items.current').text() : '通知公告'}`,
link: currentUrl,
item: items,
};
};