diff --git a/docs/forecast.md b/docs/forecast.md index 74e3d0490b..10b1e79a28 100644 --- a/docs/forecast.md +++ b/docs/forecast.md @@ -149,6 +149,19 @@ pageClass: routes +### 长沙市 + + + +可能仅限于中国大陆服务器访问,以实际情况为准。 + +| channelId | 分类 | +| --------- | ----- | +| 78 | 计划停水 | +| 157 | 抢修停水 | + + + ## 香港天文台 ### Current Weather Report diff --git a/lib/v2/tingshuitz/changsha.js b/lib/v2/tingshuitz/changsha.js new file mode 100644 index 0000000000..fc4d7a856f --- /dev/null +++ b/lib/v2/tingshuitz/changsha.js @@ -0,0 +1,43 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const baseUrl = 'http://www.supplywater.com'; + +module.exports = async (ctx) => { + const { channelId = 78 } = ctx.params; + const listPage = await got('http://www.supplywater.com/tstz-' + channelId + '.aspx'); + const $ = cheerio.load(listPage.data); + const pageName = $('.mainRightBox .news-title').text(); + const list = $('.mainRightBox .announcements-title a') + .map((_, item) => { + item = $(item); + + return { + title: item.text().trim(), + link: baseUrl + item.attr('href').trim(), + }; + }) + .get(); + + const items = await Promise.all( + list.map(async (item) => { + const postPage = await got(item.link); + const $ = cheerio.load(postPage.data); + + const data = { + title: item.title, + description: $('.mainRightBox div:last').html().trim(), + pubDate: parseDate($('.mainRightBox .gxsj span:first').text() + ' +0800', 'YYYY/M/D H:m:s ZZ'), + link: item.link, + author: $('.mainRightBox .gxsj span:last').text(), + }; + return data; + }) + ); + + ctx.state.data = { + title: `${pageName}通知 - 长沙水业集团`, + link: `${baseUrl}/fuwuzhinan.aspx`, + item: items, + }; +}; diff --git a/lib/v2/tingshuitz/maintainer.js b/lib/v2/tingshuitz/maintainer.js index 6976a2f9e6..24e7a67ac6 100644 --- a/lib/v2/tingshuitz/maintainer.js +++ b/lib/v2/tingshuitz/maintainer.js @@ -1,4 +1,5 @@ module.exports = { + '/changsha/:channelId?': ['shansing'], '/dalian': ['DIYgod'], '/dongguan': ['victoriqueko'], '/guangzhou': ['xyqfer'], diff --git a/lib/v2/tingshuitz/radar.js b/lib/v2/tingshuitz/radar.js index a40f042453..3509309cdd 100644 --- a/lib/v2/tingshuitz/radar.js +++ b/lib/v2/tingshuitz/radar.js @@ -32,6 +32,16 @@ module.exports = { }, ], }, + 'supplywater.com': { + _name: '停水通知', + www: [ + { + title: '长沙市', + docs: 'https://docs.rsshub.app/forecast.html#ting-shui-tong-zhi', + source: ['/*'], + }, + ], + }, 'whwater.com': { _name: '停水通知', '.': [ diff --git a/lib/v2/tingshuitz/router.js b/lib/v2/tingshuitz/router.js index c90302af7b..d37c37d64e 100644 --- a/lib/v2/tingshuitz/router.js +++ b/lib/v2/tingshuitz/router.js @@ -1,4 +1,5 @@ module.exports = (router) => { + router.get('/changsha/:channelId?', require('./changsha')); router.get('/dalian', require('./dalian')); router.get('/dongguan', require('./dongguan')); router.get('/guangzhou', require('./guangzhou'));