From 143862e8bfcd9920251417c61630aff533ed062d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=89=E5=87=89?= Date: Wed, 17 Oct 2018 01:09:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=EF=BC=9A=E5=81=9C=E6=B0=B4?= =?UTF-8?q?=E9=80=9A=E7=9F=A5-=E5=B9=BF=E5=B7=9E=E5=B8=82=20(#904)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README.md | 2 ++ router.js | 1 + routes/tingshuitz/guangzhou.js | 37 ++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 routes/tingshuitz/guangzhou.js diff --git a/docs/README.md b/docs/README.md index 0f594f093..e687cb74d 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1427,6 +1427,8 @@ Category 列表: + + ### 中央气象台 diff --git a/router.js b/router.js index 4145de3c7..85629f517 100644 --- a/router.js +++ b/router.js @@ -335,6 +335,7 @@ router.get('/bjnews/:cat', require('./routes/bjnews/news')); router.get('/tingshuitz/hangzhou', require('./routes/tingshuitz/hangzhou')); router.get('/tingshuitz/xiaoshan', require('./routes/tingshuitz/xiaoshan')); router.get('/tingshuitz/dalian', require('./routes/tingshuitz/dalian')); +router.get('/tingshuitz/guangzhou', require('./routes/tingshuitz/guangzhou')); // MIUI 更新 router.get('/miui/:device/:type?', require('./routes/miui/index')); diff --git a/routes/tingshuitz/guangzhou.js b/routes/tingshuitz/guangzhou.js new file mode 100644 index 000000000..e9440bcff --- /dev/null +++ b/routes/tingshuitz/guangzhou.js @@ -0,0 +1,37 @@ +const axios = require('../../utils/axios'); +const cheerio = require('cheerio'); +const iconv = require('iconv-lite'); + +module.exports = async (ctx) => { + const url = 'http://www.gzwatersupply.com/stop/stopgl.html2?tab=9'; + const response = await axios({ + responseType: 'arraybuffer', + method: 'get', + url: url, + }); + + const data = response.data; + const $ = cheerio.load(iconv.decode(data, 'gb2312')); + const list = $('table') + .eq(37) + .find('tr'); + + ctx.state.data = { + title: '停水通知 - 广州市自来水公司', + link: 'http://www.gzwatersupply.com/stop/stopgl.html2?tab=9', + item: + list && + list + .map((index, item) => { + item = $(item); + + const title = item.text(); + return { + title, + description: `广州市停水通知:${title}`, + link: `http://www.gzwatersupply.com/stop/${item.find('.new2').attr('href')}`, + }; + }) + .get(), + }; +};