添加最新政策 (#1448)

close #1447
This commit is contained in:
SettingDust
2019-01-23 11:35:20 +08:00
committed by DIYgod
parent 85769c6780
commit d7b7c5fa1b
3 changed files with 31 additions and 0 deletions

View File

@@ -2819,3 +2819,7 @@ board 和 build 可在[这里](http://api.ineal.me/tss/status)查看
### 创业邦
<route name="作者" author="xyqfer" example="/cyzone/author/1225562" path="/cyzone/author/:id" :paramsDesc="['作者 id']"/>
### 政府
<route name="最新政策" author="SettingDust" example="/gov/zhengce/zuixin" path="/gov/zhengce/zuixin"/>

View File

@@ -1001,6 +1001,9 @@ router.get('/duozhuayu/search/:wd', require('./routes/duozhuayu/search'));
// 创业邦
router.get('/cyzone/author/:id', require('./routes/cyzone/author'));
// 政府
router.get('/gov/zhengce/zuixin', require('./routes/gov/zhengce/zuixin'));
// 小黑盒
router.get('/xiaoheihe/user/:id', require('./routes/xiaoheihe/user'));

View File

@@ -0,0 +1,24 @@
const axios = require('../../../utils/axios');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const link = `http://www.gov.cn/zhengce/zuixin.htm`;
const response = await axios.get(link);
const $ = cheerio.load(response.data);
ctx.state.data = {
title: `最新政策 - 中国政府网`,
link,
item: $('.news_box .list li:not(.line)')
.map((i, el) => {
const $el = $(el);
const $a = $el.find('h4 a');
return {
title: $a.text(),
description: $a.text(),
link: $a.attr('href'),
pubDate: new Date($el.find('.date').text()).toUTCString(),
};
})
.get(),
};
};