diff --git a/docs/government.md b/docs/government.md index 984537e528..e9f44990e6 100644 --- a/docs/government.md +++ b/docs/government.md @@ -198,6 +198,12 @@ pageClass: routes +## 中央纪委国家监委 + +### 审查调查 + + + ## 中华人民共和国外交部 ### 发言人表态 diff --git a/lib/router.js b/lib/router.js index d36f489e37..debcd00b35 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1495,6 +1495,9 @@ router.get('/aptonic/action', require('./routes/aptonic/action')); // 印记中文周刊 router.get('/docschina/jsweekly', require('./routes/docschina/jsweekly')); +// 中央纪委国家监委网站 +router.get('/ccdi/scdc', require('./routes/ccdi/scdc')); + // 香水时代 router.get('/nosetime/:id/:type/:sort?', require('./routes/nosetime/comment')); router.get('/nosetime/home', require('./routes/nosetime/home')); diff --git a/lib/routes/ccdi/scdc.js b/lib/routes/ccdi/scdc.js new file mode 100644 index 0000000000..71d65007a4 --- /dev/null +++ b/lib/routes/ccdi/scdc.js @@ -0,0 +1,47 @@ +const cheerio = require('cheerio'); +const got = require('@/utils/got'); +const { resolve } = require('url'); + +module.exports = async (ctx) => { + const url = 'http://www.ccdi.gov.cn/scdc/'; + const res = await got.get(url); + const $ = cheerio.load(res.data); + + const list = $('ul.list_news_dl.fixed li'); + const out = await Promise.all( + list + .map(async (index, elem) => { + elem = $(elem); + const title = elem.find('a').text(); + const link = resolve(url, elem.find('a').attr('href')); + const pubDate = new Date(elem.find('span').text()).toUTCString(); + + const item = { + title, + pubDate, + link, + }; + + const key = link; + const value = await ctx.cache.get(key); + if (value) { + item.description = value; + } else { + const response = await got.get(item.link); + const data = response.data; + const $ = cheerio.load(data); + item.description = $('div.TRS_Editor').html(); + ctx.cache.set(key, item.description); + } + + return Promise.resolve(item); + }) + .get() + ); + + ctx.state.data = { + title: '中央纪委国家监委-审查调查', + link: url, + item: out, + }; +};