diff --git a/docs/README.md b/docs/README.md index fb192ecd2..8121c49c1 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1468,6 +1468,8 @@ Category 列表: + + ### 中央气象台 diff --git a/router.js b/router.js index 8d71c3d9d..ca0d4c0f2 100644 --- a/router.js +++ b/router.js @@ -335,6 +335,7 @@ 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')); +router.get('/tingshuitz/dongguan', require('./routes/tingshuitz/dongguan')); // MIUI 更新 router.get('/miui/:device/:type?', require('./routes/miui/index')); diff --git a/routes/tingshuitz/dongguan.js b/routes/tingshuitz/dongguan.js new file mode 100644 index 000000000..9a48fca65 --- /dev/null +++ b/routes/tingshuitz/dongguan.js @@ -0,0 +1,37 @@ +const axios = require('../../utils/axios'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const url = 'http://www.djsw.com.cn/news/tstz/index.html'; + const response = await axios({ + method: 'get', + url, + }); + + const data = response.data; + const $ = cheerio.load(data); + const list = $('#cntR li'); + + ctx.state.data = { + title: $('title').text() || '停水通知 - 东莞市东江水务有限公司', + link: 'http://www.djsw.com.cn/news/tstz/index.html', + description: $('title').text() || '停水通知 - 东莞市东江水务有限公司', + item: + list && + list + .map((index, item) => { + item = $(item); + return { + title: item.find('a').text(), + description: `东莞市停水通知:${item.find('a').text()}`, + pubDate: new Date( + $(item.contents()[1]) + .text() + .slice(1, -1) + ).toUTCString(), + link: item.find('a').attr('href'), + }; + }) + .get(), + }; +};