feat(route): add 国务院政策文件库 (#11301)
* feat(route): add 国务院政策文件库 * fix wrong author * typo * refactor: migrate to v2
This commit is contained in:
parent
01e01608cc
commit
10cf5a2468
|
|
@ -1002,7 +1002,7 @@ pageClass: routes
|
|||
|
||||
<Route author="hillerliao" example="/csrc/auditstatus/:apply_id" path="/csrc/auditstatus" :paramsDesc="['事项类别id,`https://neris.csrc.gov.cn/alappl/home/xkDetail` 列表中各地址的 appMatrCde 参数']"/>
|
||||
|
||||
## 中国政府
|
||||
## 中国政府网
|
||||
|
||||
### 数据
|
||||
|
||||
|
|
@ -1040,7 +1040,7 @@ pageClass: routes
|
|||
|
||||
### 最新文件
|
||||
|
||||
<Route author="ciaranchen" example="/gov/zhengce/wenjian" path="/gov/zhengce/wenjian/:pcodeJiguan?" :paramsDesc="['文种分类。国令; 国发; 国函; 国发明电; 国办发; 国办函; 国办发明电; 其他']" />
|
||||
<Route author="ciaranchen" example="/gov/zhengce/wenjian" path="/gov/zhengce/wenjian/:pcodeJiguan?" :paramsDesc="['文种分类。国令、国发、国函、国发明电、国办发、国办函、国办发明电、其他']" />
|
||||
|
||||
### 信息稿件
|
||||
|
||||
|
|
@ -1059,6 +1059,10 @@ pageClass: routes
|
|||
|
||||
</Route>
|
||||
|
||||
### 国务院政策文件库
|
||||
|
||||
<Route author="zxx-457" example="/gov/zhengce/zhengceku/bmwj" path="/gov/zhengce/zhengceku/:department" :paramsDesc="['库名']" />
|
||||
|
||||
### 政府新闻
|
||||
|
||||
<Route author="EsuRt" example="/gov/news/:uid" path="/gov/news" :paramsDesc="['分类名']">
|
||||
|
|
|
|||
|
|
@ -1174,9 +1174,9 @@ router.get('/cyzone/author/:id', lazyloadRouteHandler('./routes/cyzone/author'))
|
|||
router.get('/cyzone/label/:name', lazyloadRouteHandler('./routes/cyzone/label'));
|
||||
|
||||
// 政府
|
||||
router.get('/gov/zhengce/zuixin', lazyloadRouteHandler('./routes/gov/zhengce/zuixin'));
|
||||
router.get('/gov/zhengce/wenjian/:pcodeJiguan?', lazyloadRouteHandler('./routes/gov/zhengce/wenjian'));
|
||||
router.get('/gov/zhengce/govall/:advance?', lazyloadRouteHandler('./routes/gov/zhengce/govall'));
|
||||
// router.get('/gov/zhengce/zuixin', lazyloadRouteHandler('./routes/gov/zhengce/zuixin'));
|
||||
// router.get('/gov/zhengce/wenjian/:pcodeJiguan?', lazyloadRouteHandler('./routes/gov/zhengce/wenjian'));
|
||||
// router.get('/gov/zhengce/govall/:advance?', lazyloadRouteHandler('./routes/gov/zhengce/govall'));
|
||||
router.get('/gov/province/:name/:category', lazyloadRouteHandler('./routes/gov/province'));
|
||||
router.get('/gov/city/:name/:category', lazyloadRouteHandler('./routes/gov/city'));
|
||||
router.get('/gov/statecouncil/briefing', lazyloadRouteHandler('./routes/gov/statecouncil/briefing'));
|
||||
|
|
|
|||
|
|
@ -1,59 +0,0 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { advance } = ctx.params;
|
||||
const link = `http://sousuo.gov.cn/list.htm`;
|
||||
const params = new URLSearchParams({
|
||||
n: 20,
|
||||
t: 'govall',
|
||||
sort: 'pubtime',
|
||||
advance: 'true',
|
||||
});
|
||||
const query = `${params.toString()}&${advance}`;
|
||||
const res = await got.get(link, {
|
||||
searchParams: query.replace(/([\u4e00-\u9fa5])/g, (str) => encodeURIComponent(str)),
|
||||
});
|
||||
const $list = cheerio.load(res.data);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `信息稿件 - 中国政府网`,
|
||||
link: `${link}?${query}`,
|
||||
item: await Promise.all(
|
||||
$list('body > div.dataBox > table > tbody > tr')
|
||||
.slice(1)
|
||||
.map(async (_, el) => {
|
||||
const item = $list(el);
|
||||
|
||||
const number = item.find('td.info').next();
|
||||
const title = item.find('td.info > a');
|
||||
const href = title.attr('href');
|
||||
|
||||
const key = `gov_zhengce: ${href}`;
|
||||
let description;
|
||||
const value = await ctx.cache.get(key);
|
||||
|
||||
if (value) {
|
||||
description = value;
|
||||
} else {
|
||||
try {
|
||||
const contentData = await got.get(href);
|
||||
const $content = cheerio.load(contentData.data);
|
||||
description = $content('#UCAP-CONTENT').html();
|
||||
} catch (error) {
|
||||
description = '文章已被删除';
|
||||
}
|
||||
|
||||
ctx.cache.set(key, description);
|
||||
}
|
||||
|
||||
return {
|
||||
title: number.text() + ' | ' + title.text(),
|
||||
description,
|
||||
link: href,
|
||||
};
|
||||
})
|
||||
.get()
|
||||
),
|
||||
};
|
||||
};
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const queryString = require('query-string');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { pcodeJiguan } = ctx.params;
|
||||
const link = `http://sousuo.gov.cn/list.htm`;
|
||||
const res = await got.get(link, {
|
||||
searchParams: queryString.stringify({
|
||||
n: 20,
|
||||
sort: 'pubtime',
|
||||
t: 'paper',
|
||||
pcodeJiguan: pcodeJiguan ? pcodeJiguan : '',
|
||||
}),
|
||||
});
|
||||
const $list = cheerio.load(res.data);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `最新文件 - 中国政府网`,
|
||||
link,
|
||||
item: await Promise.all(
|
||||
$list('body > div.dataBox > table > tbody > tr')
|
||||
.slice(1)
|
||||
.map(async (_, el) => {
|
||||
const item = $list(el);
|
||||
|
||||
const number = item.find('td.info').next();
|
||||
const title = item.find('td.info > a');
|
||||
const href = title.attr('href');
|
||||
|
||||
const key = `gov_zhengce: ${href}`;
|
||||
let description;
|
||||
const value = await ctx.cache.get(key);
|
||||
|
||||
if (value) {
|
||||
description = value;
|
||||
} else {
|
||||
const contentData = await got.get(href);
|
||||
const $content = cheerio.load(contentData.data);
|
||||
description = $content('#UCAP-CONTENT').html();
|
||||
ctx.cache.set(key, description);
|
||||
}
|
||||
|
||||
return {
|
||||
title: number.text() + ' | ' + title.text(),
|
||||
description,
|
||||
link: href,
|
||||
};
|
||||
})
|
||||
.get()
|
||||
),
|
||||
};
|
||||
};
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const link = `http://www.gov.cn/zhengce/zuixin.htm`;
|
||||
const listData = await got.get(link);
|
||||
const $list = cheerio.load(listData.data);
|
||||
ctx.state.data = {
|
||||
title: `最新政策 - 中国政府网`,
|
||||
link,
|
||||
item: await Promise.all(
|
||||
$list('.news_box .list li:not(.line)')
|
||||
.map(async (_, el) => {
|
||||
const $el = $list(el);
|
||||
const $a = $el.find('h4 a');
|
||||
const href = $a.attr('href');
|
||||
const link = href.startsWith('/zhengce') ? `http://www.gov.cn${href}` : href;
|
||||
const key = `gov_zhengce_zuixin: ${link}`;
|
||||
let description;
|
||||
const value = await ctx.cache.get(key);
|
||||
|
||||
if (value) {
|
||||
description = value;
|
||||
} else {
|
||||
const contentData = await got.get(link);
|
||||
const $content = cheerio.load(contentData.data);
|
||||
description = $content('#UCAP-CONTENT').html();
|
||||
ctx.cache.set(key, description);
|
||||
}
|
||||
|
||||
return {
|
||||
title: $a.text(),
|
||||
description,
|
||||
guid: href,
|
||||
link,
|
||||
pubDate: new Date($el.find('.date').text()).toUTCString(),
|
||||
};
|
||||
})
|
||||
.get()
|
||||
),
|
||||
};
|
||||
};
|
||||
|
|
@ -35,6 +35,10 @@ module.exports = {
|
|||
'/pbc/tradeAnnouncement': ['nczitzk'],
|
||||
'/pbc/zcyj': ['Fatpandac'],
|
||||
'/stats/:path+': ['bigfei'],
|
||||
'/zhengce/govall/:advance?': ['ciaranchen'],
|
||||
'/zhengce/wenjian/:pcodeJiguan?': ['ciaranchen'],
|
||||
'/zhengce/zhengceku/:department': ['zxx-457'],
|
||||
'/zhengce/zuixin': ['SettingDust'],
|
||||
// province
|
||||
'/anhui/kjt/:path?': ['nczitzk'],
|
||||
'/beijing/bphc/:channel': ['bigfei'],
|
||||
|
|
|
|||
|
|
@ -776,6 +776,35 @@ module.exports = {
|
|||
},
|
||||
],
|
||||
},
|
||||
'www.gov.cn': {
|
||||
_name: '中国政府网',
|
||||
'.': [
|
||||
{
|
||||
title: '最新政策',
|
||||
docs: 'https://docs.rsshub.app/government.html#zhong-guo-zheng-fu-wang',
|
||||
source: ['/zhengce/zuixin.htm', '/'],
|
||||
target: '/gov/zhengce/zuixin',
|
||||
},
|
||||
{
|
||||
title: '最新文件',
|
||||
docs: 'https://docs.rsshub.app/government.html#zhong-guo-zheng-fu-wang',
|
||||
source: ['/'],
|
||||
target: '/gov/zhengce/wenjian',
|
||||
},
|
||||
{
|
||||
title: '信息稿件',
|
||||
docs: 'https://docs.rsshub.app/government.html#zhong-guo-zheng-fu-wang',
|
||||
source: ['/'],
|
||||
target: '/gov/zhengce/govall',
|
||||
},
|
||||
{
|
||||
title: '国务院政策文件库',
|
||||
docs: 'https://docs.rsshub.app/government.html#zhong-guo-zheng-fu-wang',
|
||||
source: ['/zhengce/zhengceku/:lib'],
|
||||
target: (params) => `/gov/zhengce/zhengceku/${params.libs}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
'xz.gov.cn': {
|
||||
_name: '徐州市人民政府',
|
||||
hrss: [
|
||||
|
|
|
|||
|
|
@ -27,6 +27,10 @@ module.exports = function (router) {
|
|||
router.get('/pbc/tradeAnnouncement', require('./pbc/tradeAnnouncement'));
|
||||
router.get('/pbc/zcyj', require('./pbc/zcyj'));
|
||||
router.get(/stats(\/[\w/-]+)?/, require('./stats'));
|
||||
router.get('/zhengce/govall/:advance?', require('./zhengce/govall'));
|
||||
router.get('/zhengce/wenjian/:pcodeJiguan?', require('./zhengce/wenjian'));
|
||||
router.get('/zhengce/zhengceku/:department', require('./zhengce/zhengceku'));
|
||||
router.get('/zhengce/zuixin', require('./zhengce/zuixin'));
|
||||
// province
|
||||
router.get(/anhui\/kjt\/([\w\d/-]+)?/, require('./anhui/kjt'));
|
||||
router.get(/beijing\/bphc(\/[\w/-]+)?/, require('./beijing/bphc'));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { advance } = ctx.params;
|
||||
const link = `http://sousuo.gov.cn/list.htm`;
|
||||
const params = new URLSearchParams({
|
||||
n: 20,
|
||||
t: 'govall',
|
||||
sort: 'pubtime',
|
||||
advance: 'true',
|
||||
});
|
||||
const query = `${params.toString()}&${advance}`;
|
||||
const res = await got.get(link, {
|
||||
searchParams: query.replace(/([\u4e00-\u9fa5])/g, (str) => encodeURIComponent(str)),
|
||||
});
|
||||
const $ = cheerio.load(res.data);
|
||||
|
||||
const list = $('body > div.dataBox > table > tbody > tr')
|
||||
.slice(1)
|
||||
.toArray()
|
||||
.map((elem) => {
|
||||
elem = $(elem);
|
||||
return {
|
||||
title: elem.find('td:nth-child(2) > a').text(),
|
||||
link: elem.find('td:nth-child(2) > a').attr('href'),
|
||||
pubDate: timezone(parseDate(elem.find('td:nth-child(5)').text()), 8),
|
||||
};
|
||||
});
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
let description = '';
|
||||
try {
|
||||
const contentData = await got(item.link);
|
||||
const $ = cheerio.load(contentData.data);
|
||||
description = $('#UCAP-CONTENT').html();
|
||||
} catch (error) {
|
||||
description = '文章已被删除';
|
||||
}
|
||||
item.description = description;
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '信息稿件 - 中国政府网',
|
||||
link: `${link}?${query}`,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { pcodeJiguan } = ctx.params;
|
||||
const link = 'http://sousuo.gov.cn/list.htm';
|
||||
const res = await got(link, {
|
||||
searchParams: {
|
||||
n: ctx.query.limit ? Number(ctx.query.limit) : 20,
|
||||
sort: 'pubtime',
|
||||
t: 'paper',
|
||||
pcodeJiguan: pcodeJiguan ? pcodeJiguan : '',
|
||||
},
|
||||
});
|
||||
const $ = cheerio.load(res.data);
|
||||
|
||||
const list = $('body > div.dataBox > table > tbody > tr')
|
||||
.slice(1)
|
||||
.toArray()
|
||||
.map((elem) => {
|
||||
elem = $(elem);
|
||||
return {
|
||||
title: elem.find('td:nth-child(2) > a').text(),
|
||||
link: elem.find('td:nth-child(2) > a').attr('href'),
|
||||
pubDate: timezone(parseDate(elem.find('td:nth-child(5)').text()), 8),
|
||||
};
|
||||
});
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const contentData = await got(item.link);
|
||||
const $ = cheerio.load(contentData.data);
|
||||
item.description = $('#UCAP-CONTENT').html();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '最新文件 - 中国政府网',
|
||||
link: res.url,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
const buildData = require('@/utils/common-config');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const department = ctx.params.department;
|
||||
const link = `http://www.gov.cn/zhengce/zhengceku/${department}/`;
|
||||
|
||||
ctx.state.data = await buildData({
|
||||
link,
|
||||
url: link,
|
||||
title: `%title%`,
|
||||
description: '政府文件库, 当页的所有列表',
|
||||
params: {
|
||||
title: `$('.channel_tab > .noline > a').text().trim() + ' - 政府文件库'`,
|
||||
},
|
||||
item: {
|
||||
item: '.news_box > .list > ul > li:not(.line)',
|
||||
title: `$('h4 > a').text()`,
|
||||
link: `$('h4 > a').attr('href')`,
|
||||
pubDate: `parseDate($('h4 > .date').text().trim())`,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const baseUrl = 'http://www.gov.cn';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const link = `${baseUrl}/zhengce/zuixin.htm`;
|
||||
const listData = await got(link);
|
||||
const $ = cheerio.load(listData.data);
|
||||
|
||||
const list = $('.news_box .list li:not(.line)')
|
||||
.toArray()
|
||||
.map((elem) => {
|
||||
elem = $(elem);
|
||||
return {
|
||||
title: elem.find('h4 a').text(),
|
||||
link: new URL(elem.find('h4 a').attr('href'), baseUrl).href,
|
||||
pubDate: timezone(parseDate(elem.find('h4 .date').text()), 8),
|
||||
};
|
||||
});
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const contentData = await got(item.link);
|
||||
const $ = cheerio.load(contentData.data);
|
||||
item.description = $('#UCAP-CONTENT').html();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '最新政策 - 中国政府网',
|
||||
link,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue