feat: 添加武汉市停水通知 (#2622)
This commit is contained in:
@@ -72,6 +72,10 @@ pageClass: routes
|
||||
|
||||
<Route author="ocleo1" example="/tingshuitz/nanjing" path="/tingshuitz/nanjing"/>
|
||||
|
||||
### 武汉市
|
||||
|
||||
<Route author="MoonBegonia" example="/tingshuitz/wuhan" path="/tingshuitz/wuhan"/>
|
||||
|
||||
## 香港天文台
|
||||
|
||||
### Current Weather Report
|
||||
|
||||
@@ -314,6 +314,7 @@ router.get('/tingshuitz/dongguan', require('./routes/tingshuitz/dongguan'));
|
||||
router.get('/tingshuitz/xian', require('./routes/tingshuitz/xian'));
|
||||
router.get('/tingshuitz/yangjiang', require('./routes/tingshuitz/yangjiang'));
|
||||
router.get('/tingshuitz/nanjing', require('./routes/tingshuitz/nanjing'));
|
||||
router.get('/tingshuitz/wuhan', require('./routes/tingshuitz/wuhan'));
|
||||
|
||||
// 米哈游
|
||||
router.get('/mihoyo/bh3/:type', require('./routes/mihoyo/bh3'));
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const url = require('url');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const baseUrl = 'https://www.whwater.com/gsfw/tstz/';
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: baseUrl,
|
||||
});
|
||||
|
||||
const data = response.data;
|
||||
const $ = cheerio.load(data);
|
||||
const list = $('.z4');
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text() || '停水通知 - 武汉市水务集团有限公司',
|
||||
link: 'https://www.whwater.com/gsfw/tstz/',
|
||||
description: $('meta[name="description"]').attr('content') || $('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.find('span').text()).toUTCString(),
|
||||
link: `${url.resolve(baseUrl, item.find('a').attr('href'))}`,
|
||||
};
|
||||
})
|
||||
.get(),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user