增加:停水通知 - 东莞市 (#944)
This commit is contained in:
@@ -1468,6 +1468,8 @@ Category 列表:
|
||||
|
||||
<route name="广州市" author="xyqfer" example="/tingshuitz/guangzhou" path="/tingshuitz/guangzhou"/>
|
||||
|
||||
<route name="东莞市" author="victoriqueko" example="/tingshuitz/dongguan" path="/tingshuitz/dongguan"/>
|
||||
|
||||
### 中央气象台
|
||||
|
||||
<route name="全国气象预警" author="ylc395" example="/weatheralarm" path="/weatheralarm">
|
||||
|
||||
@@ -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'));
|
||||
|
||||
@@ -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(),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user