From d7b7c5fa1be4d73b0aedf70cddcd8ee8f95b9a46 Mon Sep 17 00:00:00 2001 From: SettingDust Date: Wed, 23 Jan 2019 11:35:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9C=80=E6=96=B0=E6=94=BF?= =?UTF-8?q?=E7=AD=96=20(#1448)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit close #1447 --- docs/README.md | 4 ++++ lib/router.js | 3 +++ lib/routes/gov/zhengce/zuixin.js | 24 ++++++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 lib/routes/gov/zhengce/zuixin.js diff --git a/docs/README.md b/docs/README.md index 7adaef73c6..fb9b52d41d 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2819,3 +2819,7 @@ board 和 build 可在[这里](http://api.ineal.me/tss/status)查看 ### 创业邦 + +### 政府 + + diff --git a/lib/router.js b/lib/router.js index 4c2229e70d..6bc43d4f15 100644 --- a/lib/router.js +++ b/lib/router.js @@ -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')); diff --git a/lib/routes/gov/zhengce/zuixin.js b/lib/routes/gov/zhengce/zuixin.js new file mode 100644 index 0000000000..6218a1a6ec --- /dev/null +++ b/lib/routes/gov/zhengce/zuixin.js @@ -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(), + }; +};