diff --git a/docs/government.md b/docs/government.md index 703dce8164..77a708ef01 100644 --- a/docs/government.md +++ b/docs/government.md @@ -154,3 +154,11 @@ pageClass: routes ### 公示 + +## 中华人民共和国退役军人事务部 + +### 部内信息 + + +### 政策解读 + diff --git a/lib/router.js b/lib/router.js index 1dff4884c5..6518f89518 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1377,6 +1377,10 @@ router.get('/maoyan/upcoming', require('./routes/maoyan/upcoming')); // cnBeta router.get('/cnbeta', require('./routes/cnbeta/home')); +// 退伍士兵信息 +router.get('/gov/veterans/bnxx', require('./routes/gov/veterans/bnxx')); +router.get('/gov/veterans/zcjd', require('./routes/gov/veterans/zcjd')); + // Dilbert Comic Strip router.get('/dilbert/strip', require('./routes/dilbert/strip')); diff --git a/lib/routes/gov/veterans/bnxx.js b/lib/routes/gov/veterans/bnxx.js new file mode 100644 index 0000000000..fc0063f065 --- /dev/null +++ b/lib/routes/gov/veterans/bnxx.js @@ -0,0 +1,62 @@ +const axios = require('@/utils/got'); +const host = 'http://www.mva.gov.cn/sy/xx/bnxx/'; +const cheerio = require('cheerio'); +async function load(link, ctx) { + const cache = await ctx.cache.get(link); + if (cache) { + return cache; + } + + const response = await axios.get(link); + const $ = cheerio.load(response.data); + const introduce = $('#div_zhengwen > div').text(); + const temp = $('#main > div.outerlayer > div > div > div.article-info').text(); + const pubDate = temp.substring(3, 20); + const author = temp.substring(24, temp.indexOf('分享到')); + + const detailResult = `${introduce}`; + + // 定义description,并指定内容 + const description = detailResult; + await ctx.cache.set(link, description); + return { + description, + link: link, + pubDate: pubDate, + author: author, + }; +} + +module.exports = async (ctx) => { + const page = host; + const response = await axios({ + method: 'get', + url: page, + }); + const data = response.data; + + const $ = cheerio.load(data); + const list = $('#main > div.overview.container.clearfix > div.overview-right.fr > div > div.public_list_team > ul > li > a').get(); + + const process = await Promise.all( + list.map(async (item) => { + let itemUrl = $(item).attr('href'); + if (itemUrl.indexOf('./') === 0) { + itemUrl = host + itemUrl.substring(2); + } + const single = { + title: $(item).text(), + link: itemUrl, + guid: itemUrl, + }; + const other = await load(String(itemUrl), ctx); + return Promise.resolve(Object.assign({}, single, other)); + }) + ); + ctx.state.data = { + title: `中华人民共和国退役军人事务部 - 部内信息`, + link: `http://www.mva.gov.cn/sy/xx/bnxx`, + description: `中华人民共和国退役军人事务部-部内信息更新提示`, + item: process, + }; +}; diff --git a/lib/routes/gov/veterans/zcjd.js b/lib/routes/gov/veterans/zcjd.js new file mode 100644 index 0000000000..828cb0b35a --- /dev/null +++ b/lib/routes/gov/veterans/zcjd.js @@ -0,0 +1,62 @@ +const axios = require('@/utils/got'); +const host = 'http://www.mva.gov.cn/jiedu/zcjd/'; +const cheerio = require('cheerio'); +async function load(link, ctx) { + const cache = await ctx.cache.get(link); + if (cache) { + return cache; + } + + const response = await axios.get(link); + const $ = cheerio.load(response.data); + const introduce = $('#div_zhengwen > div').text(); + const temp = $('#main > div.outerlayer > div > div > div.article-info').text(); + const pubDate = temp.substring(3, 20); + const author = temp.substring(24, temp.indexOf('分享到')); + + const detailResult = `${introduce}`; + + // 定义description,并指定内容 + const description = detailResult; + await ctx.cache.set(link, description); + return { + description, + link: link, + pubDate: pubDate, + author: author, + }; +} + +module.exports = async (ctx) => { + const page = host; + const response = await axios({ + method: 'get', + url: page, + }); + const data = response.data; + + const $ = cheerio.load(data); + const list = $('#main > div.overview.container.clearfix > div.overview-right.fr > div > div.public_list_team > ul > li > a').get(); + + const process = await Promise.all( + list.map(async (item) => { + let itemUrl = $(item).attr('href'); + if (itemUrl.indexOf('./') === 0) { + itemUrl = host + itemUrl.substring(2); + } + const single = { + title: $(item).text(), + link: itemUrl, + guid: itemUrl, + }; + const other = await load(String(itemUrl), ctx); + return Promise.resolve(Object.assign({}, single, other)); + }) + ); + ctx.state.data = { + title: `中华人民共和国退役军人事务部 - 政策解读`, + link: `http://www.mva.gov.cn/sy/xx/bnxx`, + description: `中华人民共和国退役军人事务部-政策解读更新提示`, + item: process, + }; +};