fix(route): 广东省深圳市人民政府 - 通知公告 (#10910)

* fix(route): 广东省深圳市人民政府 - 通知公告

页面改版导致内容和时间异常

* chore: use parseDate

* refactor: migrate to v2
This commit is contained in:
Bang-Bo
2022-09-27 04:04:43 +08:00
committed by GitHub
parent f660fc4564
commit 4271262854
6 changed files with 42 additions and 26 deletions
+4 -4
View File
@@ -106,13 +106,13 @@ pageClass: routes
## 德阳市人民政府
### 德阳市政府公开信息
### 政府公开信息
<Route author="zytomorrow" example="/gov/sichuan/deyang/govpulicinfo/绵竹市" path="/gov/sichuan/deyang/govpulicinfo/:countyName" :paramsDesc="['区县名(**其他区县整改中,暂时只支持`绵竹市`**)。德阳市、绵竹市、广汉市、什邡市、中江县、罗江区、旌阳区、高新区']"/>
## 广东省人民政府
### 广东省教育厅
### 省教育厅
<Route author="nczitzk" example="/gov/guangdong/edu/tzgg" path="/gov/guangdong/edu/:caty" :paramsDesc="['资讯类别']">
@@ -122,7 +122,7 @@ pageClass: routes
</Route>
### 广东省教育考试院
### 省教育考试院
<Route author="icealtria" example="/gov/guangdong/eea/kszs" path="/gov/guangdong/eea/:caty" :paramsDesc="['资讯类别']">
@@ -132,7 +132,7 @@ pageClass: routes
</Route>
### 广东省深圳市人民政府
### 深圳市人民政府
<Route author="laoxua" example="/gov/shenzhen/xxgk/zfxxgj/tzgg" path="/gov/shenzhen/xxgk/zfxxgj/:caty" :paramsDesc="['信息类别']">
+1 -1
View File
@@ -1233,7 +1233,7 @@ router.get('/gov/guangdong/edu/:caty', lazyloadRouteHandler('./routes/gov/guangd
router.get('/gov/guangdong/eea/:caty', lazyloadRouteHandler('./routes/gov/guangdong/eea'));
// 广东省深圳市
router.get('/gov/shenzhen/xxgk/zfxxgj/:caty', lazyloadRouteHandler('./routes/gov/shenzhen/xxgk/zfxxgj'));
// router.get('/gov/shenzhen/xxgk/zfxxgj/:caty', lazyloadRouteHandler('./routes/gov/shenzhen/xxgk/zfxxgj'));
// 日本国外務省記者会見
router.get('/go.jp/mofa', lazyloadRouteHandler('./routes/go.jp/mofa/main'));
+4 -3
View File
@@ -44,11 +44,12 @@ module.exports = {
'/hebei/czt/xwdt/:category?': ['nczitzk'],
'/huizhou/zwgk/:category?': ['Fatpandac'],
'/shaanxi/kjt/:id?': ['nczitzk'],
'/shenzhen/hrss/szksy/:caty/:page?': ['zlasd'],
'/shenzhen/zzb/:caty/:page?': ['zlasd'],
'/shanghai/rsj/ksxm': ['Fatpandac'],
'/shanghai/yjj/:path+': ['nczitzk'],
'/shanghai/wsjkw/yqtb': ['zcf0508'],
'/shanghai/yjj/:path+': ['nczitzk'],
'/shenzhen/hrss/szksy/:caty/:page?': ['zlasd'],
'/shenzhen/xxgk/zfxxgj/:caty': ['laoxua'],
'/shenzhen/zzb/:caty/:page?': ['zlasd'],
'/sichuan/deyang/govpulicinfo/:countyName': ['zytomorrow'],
'/taiyuan/rsj/:caty/:page?': ['2PoL'],
'/xuzhou/hrss/:category?': ['nczitzk'],
+8
View File
@@ -720,6 +720,14 @@ module.exports = {
target: '/gov/shenzhen/hrss/szksy/:caty/:page?',
},
],
xxgk: [
{
title: '深圳市人民政府',
docs: 'https://docs.rsshub.app/government.html#guang-dong-sheng-ren-min-zheng-fu-guang-dong-sheng-shen-zhen-shi-ren-min-zheng-fu',
source: ['/cn/xxgk/zfxxgj/:caty'],
target: '/gov/shenzhen/hrss/szksy/:caty/:page?',
},
],
zzb: [
{
title: '组工在线公告',
+4 -3
View File
@@ -36,11 +36,12 @@ module.exports = function (router) {
router.get('/huizhou/zwgk/:category?', require('./huizhou/zwgk/index'));
router.get('/hebei/czt/xwdt/:category?', require('./hebei/czt'));
router.get('/shaanxi/kjt/:id?', require('./shaanxi/kjt'));
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'));
router.get(/shanghai\/yjj\/([\w/-]+)?/, require('./shanghai/yjj'));
router.get('/shanghai/wsjkw/yqtb', require('./shanghai/wsjkw/yqtb'));
router.get(/shanghai\/yjj\/([\w/-]+)?/, require('./shanghai/yjj'));
router.get('/shenzhen/hrss/szksy/:caty/:page?', require('./shenzhen/hrss/szksy/index'));
router.get('/shenzhen/xxgk/zfxxgj/:caty', require('./shenzhen/xxgk/zfxxgj'));
router.get('/shenzhen/zzb/:caty/:page?', require('./shenzhen/zzb/index'));
router.get('/sichuan/deyang/govpulicinfo/:countyName', require('./sichuan/deyang/govpulicinfo'));
router.get('/taiyuan/rsj/:caty/:page?', require('./taiyuan/rsj'));
router.get('/xuzhou/hrss/:category?', require('./xuzhou/hrss'));
@@ -1,7 +1,7 @@
const url = require('url');
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const timezone = require('@/utils/timezone');
const rootUrl = 'http://www.sz.gov.cn/cn/xxgk/zfxxgj/';
const config = {
@@ -26,33 +26,39 @@ const config = {
module.exports = async (ctx) => {
const cfg = config[ctx.params.caty];
if (!cfg) {
throw Error('Bad category. See <a href="https://docs.rsshub.app/government.html#guang-dong-sheng-jiao-yu-ting">docs</a>');
throw Error('Bad category. See <a href="https://docs.rsshub.app/government.html#guang-dong-sheng-ren-min-zheng-fu-guang-dong-sheng-shen-zhen-shi-ren-min-zheng-fu">docs</a>');
}
const currentUrl = url.resolve(rootUrl, cfg.link);
const response = await got({ method: 'get', url: currentUrl });
const currentUrl = new URL(cfg.link, rootUrl).href;
const response = await got(currentUrl);
const $ = cheerio.load(response.data);
const list = $('div.zx_ml_list ul li span.tit')
.map((_, item) => {
.toArray()
.map((item) => {
item = $(item).find('a');
return {
title: item.text(),
link: item.attr('href'),
};
})
.get();
});
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({ method: 'get', url: item.link });
const detailResponse = await got(item.link);
const content = cheerio.load(detailResponse.data);
item.description = content('div.concent_center').html();
item.pubDate = new Date(
content('td[align="right"]')
.text()
.replace(/发布日期:/, '') + ' GMT+8'
).toUTCString();
item.description = content('div.news_cont_d_wrap').html();
if (content('div.fjdown').html() !== null) {
item.description += content('div.fjdown').html();
}
item.pubDate = timezone(
parseDate(
content('.tit span:nth-child(2)')
.text()
.replace(/信息提供日期:/, '')
),
8
);
return item;
})
)