添加对中国天气网全国气象预警的支持 (#527)

This commit is contained in:
叡山电车
2018-08-24 19:18:55 +08:00
committed by DIYgod
parent b1ebc76920
commit 8124d5f751
7 changed files with 105 additions and 1 deletions
+2
View File
@@ -254,6 +254,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
- 笔趣阁
- UU 看书
- 文学迷
- 中国天气网
- 全国气象预警
- Gitlab
- Explore
+10
View File
@@ -2078,6 +2078,16 @@ type,必选,目前支持两种,`hot` 代表热门游记,`latest` 代表
举例网址:https://www.wenxuemi.com/files/article/html/6/6144/
### 中国气象网 <Author uid="ylc395"/>
#### 全国气象预警
举例: <(https://rsshub.app/weatherAlarm>
路由: `/weatherAlarm`
参数: 无(提示: 可以使用全局过滤参数订阅您感兴趣的地区的信息)
## Gitlab
### Explore <Author uid="imlonghao"/>
+3
View File
@@ -454,6 +454,9 @@ router.get('/novel/biquge/:id', require('./routes/novel/biquge'));
router.get('/novel/uukanshu/:uid', require('./routes/novel/uukanshu'));
router.get('/novel/wenxuemi/:id1/:id2', require('./routes/novel/wenxuemi'));
// 中国气象网
router.get('/weatherAlarm', require('./routes/weatherAlarm'));
// Gitlab
router.get('/gitlab/explore/:type', require('./routes/gitlab/explore'));
-1
View File
@@ -64,7 +64,6 @@ module.exports = async (ctx) => {
.text()
.trim()
.substring(5);
console.log($container.html());
return {
title: $el.find('a').text(),
+7
View File
@@ -0,0 +1,7 @@
{
"01": "蓝色",
"02": "黄色",
"03": "橙色",
"04": "红色",
"05": "白色"
}
+36
View File
@@ -0,0 +1,36 @@
const axios = require('../../utils/axios');
const DateTime = require('luxon').DateTime;
// 映射信息复制自网页的JS代码 http://i.tq121.com.cn/j/data_alarm.js
const gradeMap = require('./gradeMapping.json');
const typeMap = require('./typeMapping.json');
module.exports = async (ctx) => {
const alarmInfoURL = `http://product.weather.com.cn/alarm/grepalarm_cn.php?_=${Date.now()}`;
const jsonString = (await axios.get(alarmInfoURL)).data.slice(14, -1);
const alaramData = JSON.parse(jsonString).data
.map((pair) => {
const location = pair[0];
const list = pair[1].slice(0, -5).split('-');
const date = DateTime.fromFormat(list[1], 'yyyyMMddhhmmss');
const gradeCode = list[2].slice(2);
const typeCode = list[2].slice(0, 2);
return {
location,
date,
grade: gradeMap[gradeCode],
type: typeMap[typeCode],
link: `http://www.weather.com.cn/alarm/newalarmcontent.shtml?file=${pair[1]}`,
};
})
.slice(0, 30) // 取最新的30条数据
ctx.state.data = {
title: '中国天气网气象预警',
link: 'http://www.weather.com.cn/alarm/',
item: alaramData.map(item => ({
title: `${item.location}${item.date.toFormat('M月dd日HH时mm分')}发布${item.grade}${item.type}预警`,
link: item.link,
pubDate: item.date.toRFC2822(),
})),
};
};
+47
View File
@@ -0,0 +1,47 @@
{
"01": "台风",
"02": "暴雨",
"03": "暴雪",
"04": "寒潮",
"05": "大风",
"06": "沙尘暴",
"07": "高温",
"08": "干旱",
"09": "雷电",
"10": "冰雹",
"11": "霜冻",
"12": "大雾",
"13": "霾",
"14": "道路结冰",
"91": "寒冷",
"92": "灰霾",
"93": "雷雨大风",
"94": "森林火险",
"95": "降温",
"96": "道路冰雪",
"97": "干热风",
"98": "空气重污染",
"99": "低温",
"51": "海上大雾",
"52": "雷暴大风",
"53": "持续低温",
"54": "浓浮尘",
"55": "龙卷风",
"56": "低温冻害",
"57": "海上大风",
"58": "低温雨雪冰冻",
"59": "强对流",
"60": "臭氧",
"61": "大雪",
"62": "强降雨",
"63": "强降温",
"64": "雪灾",
"65": "森林(草原)火险",
"66": "雷暴",
"67": "严寒",
"68": "沙尘",
"69": "海上雷雨大风",
"70": "海上雷电",
"71": "海上台风",
"72": "低温"
}