feat(route): add 惠州市政府惠州时政 (#9065)

* feat(route): add 惠州市政府惠州时政

* fix(route): fix typo

* fix(route): remove redundant code

* fix(route): fix timezone
This commit is contained in:
Fatpandac 2022-02-10 21:54:22 +08:00 committed by GitHub
parent b73d219e70
commit 4b9844b67e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 101 additions and 0 deletions

View File

@ -128,6 +128,12 @@ pageClass: routes
</Route>
### 惠州市人民政府
#### 政务公开
<Route author="Fatpandac" example="/gov/huizhou/zwgk/jgdt" path="/gov/huizhou/zwgk/:category?" :paramsDesc="['资讯类别,可以从网址中得到,默认为政务要闻']"/>
## 国家税务总局
### 最新文件

View File

@ -0,0 +1,58 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const timezone = require('@/utils/timezone');
const rootURL = 'http://www.huizhou.gov.cn';
module.exports = async (ctx) => {
const cate = ctx.params.category ?? 'zwyw';
const url = `${rootURL}/zwgk/hzsz/${cate}`;
const response = await got(url);
const $ = cheerio.load(response.data);
const title = $('span#navigation').children('a').last().text();
const list = $('ul.ul_art_row')
.map((_, item) => ({
title: $(item).find('a').text().trim(),
link: $(item).find('a').attr('href'),
pubDate: timezone(parseDate($(item).find('li.li_art_date').text().trim()), +8),
}))
.get();
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = cheerio.load(detailResponse.data);
try {
item.description = content('div.artContent').html();
item.author = content('div.info_fbt')
.find('span.ly')
.text()
.match(/来源:(.*)/)[1];
item.pubDate = timezone(
parseDate(
content('div.info_fbt')
.find('span.time')
.text()
.match(/时间:(.*)/)[1]
),
+8
);
} catch (e) {
item.description = '';
}
return item;
})
)
);
ctx.state.data = {
title: `惠州市人民政府 - ${title}`,
link: url,
item: items,
};
};

View File

@ -5,4 +5,5 @@ module.exports = {
'/shanghai/rsj/ksxm': ['Fatpandac'],
'/guangdong/tqyb/tfxtq': ['Fatpandac'],
'/guangdong/tqyb/sncsyjxh': ['Fatpandac'],
'/huizhou/zwgk/:category?': ['Fatpandac'],
};

View File

@ -330,4 +330,39 @@ module.exports = {
},
],
},
'huizhou.gov.cn': {
_name: '惠州市人民政府',
www: [
{
title: '政务公开 - 政务要闻',
docs: 'https://docs.rsshub.app/government.html#guang-yan-an-dong-sheng-xing-xian-ren-min-zheng-zheng-fu-hui-zhou-shi-fu-ren-min-zheng-zheng-fu-zheng-zheng-wu-gong-kai',
source: ['/zwgk/hzsz/:category'],
target: (params) => {
if (params.category === 'zwyw') {
return '/gov/huizhou/zwgk/zwyw';
}
},
},
{
title: '政务公开 - 机关动态',
docs: 'https://docs.rsshub.app/government.html#guang-yan-an-dong-sheng-xing-xian-ren-min-zheng-zheng-fu-hui-zhou-shi-fu-ren-min-zheng-zheng-fu-zheng-zheng-wu-gong-kai',
source: ['/zwgk/hzsz/:category'],
target: (params) => {
if (params.category === 'jgdt') {
return '/gov/huizhou/zwgk/jgdt';
}
},
},
{
title: '政务公开 - 县区要闻',
docs: 'https://docs.rsshub.app/government.html#guang-yan-an-dong-sheng-xing-xian-ren-min-zheng-zheng-fu-hui-zhou-shi-fu-ren-min-zheng-zheng-fu-zheng-zheng-wu-gong-kai',
source: ['/zwgk/hzsz/:category'],
target: (params) => {
if (params.category === 'xqyw') {
return '/gov/huizhou/zwgk/xqyw';
}
},
},
],
},
};

View File

@ -6,4 +6,5 @@ module.exports = function (router) {
router.get('/shanghai/wsjkw/yqtb', require('./shanghai/wsjkw/yqtb'));
router.get('/guangdong/tqyb/tfxtq', require('./guangdong/tqyb/tfxtq'));
router.get('/guangdong/tqyb/sncsyjxh', require('./guangdong/tqyb/sncsyjxh'));
router.get('/huizhou/zwgk/:category?', require('./huizhou/zwgk/index'));
};