feat:增加中国退伍士兵信息公开网 (#2357)

This commit is contained in:
SunShinenny
2019-06-10 15:06:34 +08:00
committed by DIYgod
parent 60f3d43c7f
commit 595e1eb988
4 changed files with 136 additions and 0 deletions

View File

@@ -154,3 +154,11 @@ pageClass: routes
### 公示 ### 公示
<Route author="billyct" example="/gov/mee/gs" path="/gov/mee/gs"/> <Route author="billyct" example="/gov/mee/gs" path="/gov/mee/gs"/>
## 中华人民共和国退役军人事务部
### 部内信息
<Route author="SunShinenny" example="/gov/veterans/bnxx" path="/gov/veterans/bnxx"/>
### 政策解读
<Route author="SunShinenny" example="/gov/veterans/zcjd" path="/gov/veterans/zcjd"/>

View File

@@ -1377,6 +1377,10 @@ router.get('/maoyan/upcoming', require('./routes/maoyan/upcoming'));
// cnBeta // cnBeta
router.get('/cnbeta', require('./routes/cnbeta/home')); 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 // Dilbert Comic Strip
router.get('/dilbert/strip', require('./routes/dilbert/strip')); router.get('/dilbert/strip', require('./routes/dilbert/strip'));

View File

@@ -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,
};
};

View File

@@ -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,
};
};