mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat(route): 支持长沙停水通知 (#11316)
* feat(route): 支持长沙停水通知 * fix(route): 调整长沙停水通知时区和文档 * fix(radar): 修正长沙市停水通知规则 * doc: 修正长沙市停水通知示例 * refactor(route): 长沙停水通知 follows suggestions * docs(route): 长沙停水通知 follows suggestions
This commit is contained in:
@@ -149,6 +149,19 @@ pageClass: routes
|
||||
|
||||
</Route>
|
||||
|
||||
### 长沙市
|
||||
|
||||
<Route author="shansing" example="/tingshuitz/changsha/78" path="/tingshuitz/changsha/:channelId?">
|
||||
|
||||
可能仅限于中国大陆服务器访问,以实际情况为准。
|
||||
|
||||
| channelId | 分类 |
|
||||
| --------- | ----- |
|
||||
| 78 | 计划停水 |
|
||||
| 157 | 抢修停水 |
|
||||
|
||||
</Route>
|
||||
|
||||
## 香港天文台
|
||||
|
||||
### Current Weather Report
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
};
|
||||
@@ -1,4 +1,5 @@
|
||||
module.exports = {
|
||||
'/changsha/:channelId?': ['shansing'],
|
||||
'/dalian': ['DIYgod'],
|
||||
'/dongguan': ['victoriqueko'],
|
||||
'/guangzhou': ['xyqfer'],
|
||||
|
||||
@@ -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: '停水通知',
|
||||
'.': [
|
||||
|
||||
@@ -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'));
|
||||
|
||||
Reference in New Issue
Block a user