feat(route): add 河北省财政厅 (#9759)

* feat(route): add 河北省财政厅

* regenerate

* fix typo

* fix typo
This commit is contained in:
Ethan Shen 2022-05-15 22:21:42 +08:00 committed by GitHub
parent bab100a487
commit a4ce5128ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 100 additions and 0 deletions

View File

@ -725,6 +725,16 @@ pageClass: routes
</Route>
### 河北省财政厅
<Route author="nczitzk" example="/gov/hebei/czt/xwdt" path="/gov/hebei/czt/xwdt/:category?" :paramsDesc="['分类,见下表,默认为财政动态']">
| 财政动态 | 综合新闻 | 通知公告 |
| ---- | ---- | ---- |
| gzdt | zhxw | tzgg |
</Route>
### 河北省退役军人事务厅
<Route author="SunShinenny" example="/gov/veterans/hebei/sxxx" path="/gov/veterans/hebei/:type" :paramsDesc="['分类名']">

53
lib/v2/gov/hebei/czt.js Normal file
View File

@ -0,0 +1,53 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const category = ctx.params.category ?? 'gzdt';
const rootUrl = 'http://czt.hebei.gov.cn';
const currentUrl = `${rootUrl}/xwdt/${category}`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
let items = $('td li a[title]')
.toArray()
.map((item) => {
item = $(item);
return {
title: item.text(),
link: `${rootUrl}${/^\.\.\/\.\./.test(item.attr('href')) ? item.attr('href').replace(/^\.\.\/\.\./, '') : `/xwdt/${category}${item.attr('href').replace(/^\./, '')}`}`,
};
});
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.author = content('meta[name="ContentSource"]').attr('content');
item.pubDate = parseDate(content('meta[name="PubDate"]').attr('content'));
item.description = content('.TRS_Editor, .content').html();
return item;
})
)
);
ctx.state.data = {
title: $('title').text(),
link: currentUrl,
item: items,
};
};

View File

@ -17,6 +17,7 @@ module.exports = {
'/anhui/kjt/:path?': ['nczitzk'],
'/beijing/kw/:channel': ['Fatpandac'],
'/hebei/czt/xwdt/:category?': ['nczitzk'],
'/shenzhen/hrss/szksy/:caty/:page?': ['zlasd'],
'/shenzhen/zzb/:caty/:page?': ['zlasd'],
'/shanghai/rsj/ksxm': ['Fatpandac'],

View File

@ -300,6 +300,41 @@ module.exports = {
},
],
},
'hebei.gov.cn': {
_name: '河北省人民政府',
czt: [
{
title: '河北省财政厅 - 财政动态',
docs: 'https://docs.rsshub.app/government.html#he-bei-sheng-cai-zheng-ting-cai-zheng-dong-tai',
source: ['/xwdt/:category'],
target: (params) => {
if (params.category === 'gzdt') {
return '/gov/hebei/czt/xwdt/:category';
}
},
},
{
title: '河北省财政厅 - 综合新闻',
docs: 'https://docs.rsshub.app/government.html#he-bei-sheng-cai-zheng-ting-zong-he-xin-wen',
source: ['/xwdt/:category'],
target: (params) => {
if (params.category === 'zhxw') {
return '/gov/hebei/czt/xwdt/:category';
}
},
},
{
title: '河北省财政厅 - 通知公告',
docs: 'https://docs.rsshub.app/government.html#he-bei-sheng-cai-zheng-ting-tong-zhi-gong-gao',
source: ['/xwdt/:category'],
target: (params) => {
if (params.category === 'tzgg') {
return '/gov/hebei/czt/xwdt/:category';
}
},
},
],
},
'homeaffairs.gov.au': {
_name: 'Department of Home Affairs',
immi: [

View File

@ -18,6 +18,7 @@ module.exports = function (router) {
// province
router.get(/anhui\/kjt\/([\w\d/-]+)?/, require('./anhui/kjt'));
router.get('/beijing/kw/:channel', require('./beijing/kw/index'));
router.get('/hebei/czt/xwdt/:category?', require('./hebei/czt'));
router.get('/shenzhen/hrss/szksy/:caty/:page?', require('./shenzhen/hrss/szksy/index'));
router.get('/shenzhen/zzb/:caty/:page?', require('./shenzhen/zzb/index'));
router.get('/shanghai/rsj/ksxm', require('./shanghai/rsj/ksxm'));