mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-15 18:30:53 +08:00
@@ -2384,11 +2384,11 @@ type, 分类, 缺省为中港台
|
|||||||
|
|
||||||
参数: 无
|
参数: 无
|
||||||
|
|
||||||
### 中国气象网 全国气象预警 <Author uid="ylc395"/>
|
### 中央气象台 全国气象预警 <Author uid="ylc395"/>
|
||||||
|
|
||||||
举例: <https://rsshub.app/weatherAlarm>
|
举例: <https://rsshub.app/weatheralarm>
|
||||||
|
|
||||||
路由: `/weatherAlarm`
|
路由: `/weatheralarm`
|
||||||
|
|
||||||
参数: 无(提示: 可以使用全局过滤参数订阅您感兴趣的地区的信息)
|
参数: 无(提示: 可以使用全局过滤参数订阅您感兴趣的地区的信息)
|
||||||
|
|
||||||
|
|||||||
@@ -457,7 +457,7 @@ router.get('/novel/wenxuemi/:id1/:id2', require('./routes/novel/wenxuemi'));
|
|||||||
router.get('/novel/booksky/:id', require('./routes/novel/booksky'));
|
router.get('/novel/booksky/:id', require('./routes/novel/booksky'));
|
||||||
|
|
||||||
// 中国气象网
|
// 中国气象网
|
||||||
router.get('/weatherAlarm', require('./routes/weatherAlarm'));
|
router.get('/weatheralarm', require('./routes/weatheralarm'));
|
||||||
|
|
||||||
// Gitlab
|
// Gitlab
|
||||||
router.get('/gitlab/explore/:type', require('./routes/gitlab/explore'));
|
router.get('/gitlab/explore/:type', require('./routes/gitlab/explore'));
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"01": "蓝色",
|
|
||||||
"02": "黄色",
|
|
||||||
"03": "橙色",
|
|
||||||
"04": "红色",
|
|
||||||
"05": "白色"
|
|
||||||
}
|
|
||||||
@@ -1,36 +1,25 @@
|
|||||||
const axios = require('../../utils/axios');
|
const axios = require('../../utils/axios');
|
||||||
const DateTime = require('luxon').DateTime;
|
const DateTime = require('luxon').DateTime;
|
||||||
|
const cheerio = require('cheerio');
|
||||||
// 映射信息复制自网页的JS代码 http://i.tq121.com.cn/j/data_alarm.js
|
|
||||||
const gradeMap = require('./gradeMapping.json');
|
|
||||||
const typeMap = require('./typeMapping.json');
|
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
const alarmInfoURL = `http://product.weather.com.cn/alarm/grepalarm_cn.php?_=${Date.now()}`;
|
const alarmInfoURL = `http://www.nmc.cn/f/alarm.html`;
|
||||||
const jsonString = (await axios.get(alarmInfoURL)).data.slice(14, -1);
|
const html = (await axios.get(alarmInfoURL)).data;
|
||||||
const alaramData = JSON.parse(jsonString)
|
const $ = cheerio.load(html);
|
||||||
.data.map((pair) => {
|
const alarmElements = $('.alarmlist > div:not(.pagination)').toArray();
|
||||||
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 = {
|
ctx.state.data = {
|
||||||
title: '中国天气网气象预警',
|
title: '中央气象台全国气象预警',
|
||||||
link: 'http://www.weather.com.cn/alarm/',
|
link: alarmInfoURL,
|
||||||
item: alaramData.map((item) => ({
|
item: alarmElements.map((el) => {
|
||||||
title: `${item.location}${item.date.toFormat('M月dd日HH时mm分')}发布${item.grade}${item.type}预警`,
|
const $aEl = $(el).find('a');
|
||||||
link: item.link,
|
const link = $aEl.attr('href');
|
||||||
pubDate: item.date.toRFC2822(),
|
const dateString = link.match(/_(\d{14})\.html/)[1];
|
||||||
})),
|
return {
|
||||||
|
title: $aEl.text(),
|
||||||
|
link: `http://www.nmc.cn${link}`,
|
||||||
|
pubDate: DateTime.fromFormat(dateString, 'yyyyMMddhhmmss', {zone: 'utc+8'}).toRFC2822(),
|
||||||
|
};
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
{
|
|
||||||
"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": "低温"
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user