fix(route): fix gov/sichuan/deyang/govpulicinfo (#12205)
* fix(route): fix gov/sichuan/deyang/govpulicinfo * fix(route): fix gov/sichuan/deyang/govpulicinfo * fix(route): fix gov/sichuan/deyang/govpulicinfo * fix(route): fix gov/sichuan/deyang/govpulicinfo * fix(route): fix gov/sichuan/deyang/govpulicinfo * fix(route): fix gov/sichuan/deyang/govpulicinfo * fix(route): fix gov/sichuan/deyang/govpulicinfo * Update lib/v2/gov/sichuan/deyang/govpublicinfo.js * fix(route): fix gov/sichuan/deyang/govpulicinfo * Update lib/v2/gov/sichuan/deyang/govpublicinfo.js * Update lib/v2/gov/sichuan/deyang/govpublicinfo.js * fix: update radar and maintainer --------- Co-authored-by: zytomorrow <z794672847@gamil.com>
This commit is contained in:
parent
39cc75132c
commit
26e0ac6c7b
|
|
@ -148,7 +148,13 @@ pageClass: routes
|
|||
|
||||
### 政府公开信息
|
||||
|
||||
<Route author="zytomorrow" example="/gov/sichuan/deyang/govpulicinfo/绵竹市" path="/gov/sichuan/deyang/govpulicinfo/:countyName" :paramsDesc="['区县名(**其他区县整改中,暂时只支持`绵竹市`**)。德阳市、绵竹市、广汉市、什邡市、中江县、罗江区、旌阳区、高新区']"/>
|
||||
<Route author="zytomorrow" example="/gov/sichuan/deyang/govpublicinfo/绵竹市" path="/gov/sichuan/deyang/govpublicinfo/:countyName/:infoType?" :paramsDesc="['区县名(**其他区县整改中,暂时只支持`绵竹市`**)。德阳市、绵竹市、广汉市、什邡市、中江县、罗江区、旌阳区、高新区', '信息类型。默认值:fdzdnr-“法定主动内容”']">
|
||||
|
||||
| 法定主动内容 | 公示公告 |
|
||||
|:--------:|:----:|
|
||||
| fdzdnr | gsgg |
|
||||
|
||||
</Route>
|
||||
|
||||
## 广东省人民政府
|
||||
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ module.exports = {
|
|||
'/shenzhen/hrss/szksy/:caty/:page?': ['zlasd'],
|
||||
'/shenzhen/xxgk/zfxxgj/:caty': ['laoxua'],
|
||||
'/shenzhen/zzb/:caty/:page?': ['zlasd'],
|
||||
'/sichuan/deyang/govpulicinfo/:countyName': ['zytomorrow'],
|
||||
'/sichuan/deyang/govpublicinfo/:countyName/:infoType?': ['zytomorrow'],
|
||||
'/taiyuan/rsj/:caty/:page?': ['2PoL'],
|
||||
'/wuhan/sy/whyw': ['nczitzk'],
|
||||
'/xinyi/:path+': ['ShuiHuo'],
|
||||
|
|
|
|||
|
|
@ -443,7 +443,7 @@ module.exports = {
|
|||
title: '德阳市政府公开信息',
|
||||
docs: 'https://docs.rsshub.app/government.html#de-yang-shi-fu-ren-min-zheng-zheng-fu',
|
||||
source: ['/*'],
|
||||
target: '/sichuan/deyang/govpulicinfo/:countyName',
|
||||
target: '/sichuan/deyang/govpublicinfo/:countyName',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ module.exports = function (router) {
|
|||
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('/sichuan/deyang/govpublicinfo/:countyName/:infoType?', require('./sichuan/deyang/govpublicinfo'));
|
||||
router.get('/taiyuan/rsj/:caty/:page?', require('./taiyuan/rsj'));
|
||||
router.get('/wuhan/sy/whyw', require('./wuhan/whyw'));
|
||||
router.get(/xinyi(\/[\w/-]+)?/, require('./xinyi/xinyi'));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,88 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
// 各地区url信息
|
||||
const basicInfoDict = {
|
||||
绵竹市: {
|
||||
rootUrl: 'https://www.mz.gov.cn',
|
||||
infoType: {
|
||||
fdzdnr: {
|
||||
basicUrl: 'https://www.mz.gov.cn/info/iList.jsp?node_id=GKmzs&cat_id=15971&cur_page=1',
|
||||
name: '法定主动内容',
|
||||
},
|
||||
gsgg: {
|
||||
basicUrl: 'https://www.mz.gov.cn/info/iList.jsp?node_id=GKmzs&cat_id=24186&cur_page=1',
|
||||
name: '公示公告',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const getInfoUrlList = async (rootUrl, infoBasicUrl) => {
|
||||
const response = await got(infoBasicUrl);
|
||||
const $ = cheerio.load(response.data);
|
||||
// 非当前日期文章计数,部分旧文章可能会置顶,目前为发现置顶数超过10
|
||||
const infoList = $('body > div.container > div.ewb-white > div.ewb-job > ul > li').toArray().map((item) => ({
|
||||
title: $('a', item).attr('title'),
|
||||
url: `${rootUrl}${$('a', item).attr('href')}`,
|
||||
}));
|
||||
return infoList;
|
||||
};
|
||||
|
||||
// 获取信息正文内容
|
||||
const getInfoContent = (ctx, rootUrl, item) =>
|
||||
ctx.cache.tryGet(item.url, async () => {
|
||||
const response = await got(item.url);
|
||||
// 部分网页会跳转其他类型网站,则不解析,直接附超链接
|
||||
try {
|
||||
const $ = cheerio.load(response.data);
|
||||
const fileList = $('#symbol > div:nth-child(4) > div > span > a').toArray().map((item) => ({
|
||||
name: $(item).text(),
|
||||
url: `${rootUrl}/${$(item).attr('href')}`,
|
||||
}));
|
||||
const rawDate = $('#symbol > div:nth-child(1) > div:nth-child(3)').text().split(':')[1].trim();
|
||||
return {
|
||||
title: $('#main').text().trim(),
|
||||
id: $('#symbol > div:nth-child(1) > div:nth-child(1)').text().split(':')[1].trim(),
|
||||
infoNum: $('#symbol > div:nth-child(1) > div:nth-child(2) > span').text().split(':')[1].trim(),
|
||||
pubDate: parseDate(timezone(rawDate, +8)),
|
||||
date: rawDate,
|
||||
keyWord: $('#symbol > div:nth-child(2) > div:nth-child(3)').text().split(':')[1].trim(),
|
||||
source: $('#symbol > div:nth-child(2) > div:nth-child(2)').text().split(':')[1].trim(),
|
||||
content: $('#container > div.ewb-white > div.ewb-article-detail').html(),
|
||||
file: fileList,
|
||||
link: item.url,
|
||||
_isCompleteInfo: true,
|
||||
};
|
||||
} catch (err) {
|
||||
return {
|
||||
title: item.title,
|
||||
link: item.url,
|
||||
_isCompleteInfo: false,
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const countyName = ctx.params.countyName;
|
||||
const infoType = ctx.params.infoType || 'fdzdnr';
|
||||
const infoBasicUrl = basicInfoDict[countyName].infoType[infoType].basicUrl;
|
||||
const rootUrl = basicInfoDict[countyName].rootUrl;
|
||||
const infoUrlList = await getInfoUrlList(rootUrl, infoBasicUrl);
|
||||
const items = await Promise.all(infoUrlList.map((item) => getInfoContent(ctx, rootUrl, item)));
|
||||
|
||||
ctx.state.data = {
|
||||
title: `政府公开信息-${countyName}-${basicInfoDict[countyName].infoType[infoType].name}`,
|
||||
link: infoBasicUrl,
|
||||
item: items.map((item) => ({
|
||||
title: item.title,
|
||||
description: art(path.join(__dirname, './templates/govPublicInfo.art'), { item }),
|
||||
link: item.link,
|
||||
pubDate: item.pubDate,
|
||||
})),
|
||||
};
|
||||
};
|
||||
|
|
@ -1,95 +0,0 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
|
||||
// 各地区url信息
|
||||
const basicInfoDict = {
|
||||
绵竹市: {
|
||||
rootUrl: 'https://www.mz.gov.cn',
|
||||
infoUrl: 'https://www.mz.gov.cn/info/iList.jsp?tm_id=1805&cur_page=',
|
||||
},
|
||||
};
|
||||
|
||||
const getInfoUrlList = async (countyName) => {
|
||||
const url = basicInfoDict[countyName].infoUrl;
|
||||
const infoUrlList = [];
|
||||
const expectToday = new Date();
|
||||
for (let pageNum = 1; ; pageNum++) {
|
||||
let response;
|
||||
try {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
response = await got(`${url}${pageNum}`);
|
||||
} catch (err) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
response = await got(`${url}${pageNum}`, { dnsLookupIpVersion: 'ipv6' });
|
||||
}
|
||||
const $ = cheerio.load(response.data);
|
||||
const infoList = $('#list_content > ul > li');
|
||||
// 判断当前页是否有数据
|
||||
if (infoList.length !== 0) {
|
||||
for (let infoIdx = 0; infoIdx < infoList.length; infoIdx++) {
|
||||
const date = parseDate($('span', infoList[infoIdx]).html());
|
||||
// 判断当前信息日期是否是今日
|
||||
if (date.getUTCFullYear() === expectToday.getUTCFullYear() && date.getUTCMonth() === expectToday.getUTCMonth() && date.getUTCDate() === expectToday.getUTCDate() - 1) {
|
||||
infoUrlList.push(`${basicInfoDict[countyName].rootUrl}${$('a', infoList[infoIdx]).attr('href')}`);
|
||||
} else {
|
||||
return infoUrlList;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return infoUrlList;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 获取信息正文内容
|
||||
const getInfoContent = (ctx, url, countyName) =>
|
||||
ctx.cache.tryGet(url, async () => {
|
||||
let response;
|
||||
try {
|
||||
response = await got(url);
|
||||
} catch (err) {
|
||||
response = await got(url, { dnsLookupIpVersion: 'ipv6' });
|
||||
}
|
||||
const $ = cheerio.load(response.data);
|
||||
const fileNodes = $('#symbol > div:nth-child(4) > div > span > a');
|
||||
const fileList = [];
|
||||
for (let i = 0; i < fileNodes.length; i++) {
|
||||
fileList.push({
|
||||
name: $(fileNodes[i]).text(),
|
||||
url: `${basicInfoDict[countyName].rootUrl}/${$(fileNodes[i]).attr('href')}`,
|
||||
});
|
||||
}
|
||||
const rawDate = $('#symbol > div:nth-child(1) > div:nth-child(3)').text().split(':')[1].trim();
|
||||
return {
|
||||
title: $('#main').text().trim(),
|
||||
id: $('#symbol > div:nth-child(1) > div:nth-child(1)').text().split(':')[1].trim(),
|
||||
infoNum: $('#symbol > div:nth-child(1) > div:nth-child(2) > span').text().split(':')[1].trim(),
|
||||
pubDate: parseDate(rawDate),
|
||||
date: rawDate,
|
||||
keyWord: $('#symbol > div:nth-child(2) > div:nth-child(3)').text().split(':')[1].trim(),
|
||||
source: $('#symbol > div:nth-child(2) > div:nth-child(2)').text().split(':')[1].trim(),
|
||||
content: $('#container > div.ewb-white > div.ewb-article-detail').html(),
|
||||
file: fileList,
|
||||
link: url,
|
||||
};
|
||||
});
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const countyName = ctx.params.countyName;
|
||||
const infoUrlList = await getInfoUrlList(countyName);
|
||||
const items = await Promise.all(infoUrlList.map((item) => getInfoContent(ctx, item, countyName)));
|
||||
|
||||
ctx.state.data = {
|
||||
title: `政府公开信息 - ${countyName}`,
|
||||
link: basicInfoDict[countyName].infoUrl,
|
||||
item: items.map((item) => ({
|
||||
title: item.title,
|
||||
description: art(path.resolve(__dirname, './templates/govPublicInfo.art'), { item }),
|
||||
link: item.link,
|
||||
pubDate: item.pubDate,
|
||||
})),
|
||||
};
|
||||
};
|
||||
|
|
@ -1,42 +1,47 @@
|
|||
<table border="1" cellpadding="2" cellspacing="0" align="center">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>索引号</td>
|
||||
<td>{{item.id}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>文号</td>
|
||||
<td>{{item.infoNum}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>发文日期</td>
|
||||
<td>{{item.date}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>关键词</td>
|
||||
<td>{{item.keyWord}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>信息来源</td>
|
||||
<td>{{item.source}}</td>
|
||||
</tr>
|
||||
{{if item.file.length}}
|
||||
{{if item._isCompleteInfo}}
|
||||
<table border="1" cellpadding="2" cellspacing="0" align="center">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>附件</td>
|
||||
<td>
|
||||
{{each item.file}}
|
||||
<a href="{{$value.url}}">{{$value.name}}</a><br>
|
||||
{{/each}}
|
||||
</td>
|
||||
<td>索引号</td>
|
||||
<td>{{item.id}}</td>
|
||||
</tr>
|
||||
{{/if}}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<hr/>
|
||||
<div>
|
||||
{{@ item.content}}
|
||||
</div>
|
||||
<tr>
|
||||
<td>文号</td>
|
||||
<td>{{item.infoNum}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>发文日期</td>
|
||||
<td>{{item.date}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>关键词</td>
|
||||
<td>{{item.keyWord}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>信息来源</td>
|
||||
<td>{{item.source}}</td>
|
||||
</tr>
|
||||
{{if item.file.length}}
|
||||
<tr>
|
||||
<td>附件</td>
|
||||
<td>
|
||||
{{each item.file}}
|
||||
<a href="{{$value.url}}">{{$value.name}}</a><br>
|
||||
{{/each}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/if}}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<hr/>
|
||||
<div>
|
||||
{{@ item.content }}
|
||||
</div>
|
||||
{{else}}
|
||||
<div>
|
||||
<a href="{{item.link}}">{{item.title}}</a>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue