feat: add 重庆市两江新区信息公开网 (#5130)

This commit is contained in:
Ethan Shen 2020-07-07 17:28:38 +08:00 committed by GitHub
parent 4b42f53ca5
commit ef3ed0e5c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 138 additions and 0 deletions

View File

@ -433,6 +433,24 @@ pageClass: routes
<Route author="nczitzk" example="/gov/mohurd/policy" path="/gov/mohurd/policy"/>
## 重庆市人民政府
### 两江新区信息公开网
#### 党务公开
<Route author="nczitzk" example="/gov/chongqing/ljxq/dwgk" path="/gov/chongqing/ljxq/dwgk"/>
#### 政务公开
<Route author="nczitzk" example="/gov/chongqing/ljxq/zwgk/lzyj" path="/gov/chongqing/ljxq/zwgk/:caty" :paramsDesc="['分类名']">
| 履职依据 | 公示公告 |
| -------- | -------- |
| lzyj | gsgg |
</Route>
## 中央纪委国家监委
### 审查调查

View File

@ -2932,6 +2932,10 @@ router.get('/gelonghui/keyword/:keyword', require('./routes/gelonghui/keyword'))
// 光谷社区
router.get('/guanggoo/:caty', require('./routes/guanggoo/index'));
// 重庆市两江新区信息公开网
router.get('/gov/chongqing/ljxq/dwgk', require('./routes/gov/chongqing/ljxq/dwgk'));
router.get('/gov/chongqing/ljxq/zwgk/:caty', require('./routes/gov/chongqing/ljxq/zwgk'));
// 国家突发事件预警信息发布网
router.get('/12379', require('./routes/12379/index'));

View File

@ -0,0 +1,48 @@
const url = require('url');
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const rootUrl = 'http://ljxq.cq.gov.cn/dwgk/';
const response = await got({
method: 'get',
url: rootUrl,
});
const $ = cheerio.load(response.data);
const list = $('div.gl-c-r-content ul li')
.slice(0, 10)
.map((_, item) => {
item = $(item);
const a = item.find('a');
return {
title: a.text(),
link: url.resolve(rootUrl, a.attr('href')),
pubDate: new Date(item.find('span').text() + ' GMT+8').toUTCString(),
};
})
.get();
const items = await Promise.all(
list.map(
async (item) =>
await ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
});
const content = cheerio.load(detailResponse.data);
item.description = content('div.zwxl-article').html();
return item;
})
)
);
ctx.state.data = {
title: '两江新区信息公开网 - 党务公开',
link: rootUrl,
item: items,
};
};

View File

@ -0,0 +1,68 @@
const url = require('url');
const got = require('@/utils/got');
const cheerio = require('cheerio');
const rootUrl = 'http://ljxq.cq.gov.cn';
const config = {
lzyj: {
link: '/zwgk_199/fdzdgknr/zcwj/',
title: '履职依据',
},
gsgg: {
link: '/zwgk_199/fdzdgknr/gggs/',
title: '公示公告',
},
};
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#zhong-qing-shi-ren-min-zheng-fu-liang-jiang-xin-qu-xin-xi-gong-kai-wang-zheng-wu-gong-kai">docs</a>');
}
const currentUrl = url.resolve(rootUrl, cfg.link);
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
$('tr.cwx-tit').remove();
const list = $('table.cwx-table tbody tr')
.slice(0, 10)
.map((_, item) => {
item = $(item);
const a = item.find('a');
return {
title: a.text(),
link: url.resolve(currentUrl, a.attr('href')),
pubDate: new Date(item.find('td').eq(2).text() + ' GMT+8').toUTCString(),
};
})
.get();
const items = await Promise.all(
list.map(
async (item) =>
await ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
});
const content = cheerio.load(detailResponse.data);
item.description = content('div.zwxl-main').html();
return item;
})
)
);
ctx.state.data = {
title: `两江新区信息公开网 - ${cfg.title}`,
link: rootUrl,
item: items,
};
};