mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 23:00:48 +08:00
feat: 修复路由 预报预警|全国气象预警 (#4511)
This commit is contained in:
@@ -98,7 +98,7 @@ pageClass: routes
|
|||||||
|
|
||||||
### 全国气象预警
|
### 全国气象预警
|
||||||
|
|
||||||
<Route author="ylc395" example="/weatheralarm" path="/weatheralarm">
|
<Route author="ylc395" example="/weatheralarm/广东省" path="/weatheralarm/:province?" :paramsDesc="['省份']">
|
||||||
|
|
||||||
可通过全局过滤参数订阅您感兴趣的地区.
|
可通过全局过滤参数订阅您感兴趣的地区.
|
||||||
|
|
||||||
|
|||||||
@@ -528,7 +528,7 @@ router.get('/novel/ptwxz/:id1/:id2', require('./routes/novel/ptwxz'));
|
|||||||
router.get('/novel/zhaishuyuan/:id', require('./routes/novel/zhaishuyuan'));
|
router.get('/novel/zhaishuyuan/:id', require('./routes/novel/zhaishuyuan'));
|
||||||
|
|
||||||
// 中国气象网
|
// 中国气象网
|
||||||
router.get('/weatheralarm', require('./routes/weatheralarm'));
|
router.get('/weatheralarm/:province?', require('./routes/weatheralarm'));
|
||||||
|
|
||||||
// Gitlab
|
// Gitlab
|
||||||
router.get('/gitlab/explore/:type', require('./routes/gitlab/explore'));
|
router.get('/gitlab/explore/:type', require('./routes/gitlab/explore'));
|
||||||
|
|||||||
@@ -1,23 +1,25 @@
|
|||||||
const got = require('@/utils/got');
|
const got = require('@/utils/got');
|
||||||
const cheerio = require('cheerio');
|
|
||||||
const date = require('@/utils/date');
|
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
const alarmInfoURL = 'http://www.nmc.cn/f/alarm.html';
|
const province = encodeURIComponent(ctx.params.province) || '&';
|
||||||
const html = (await got.get(alarmInfoURL)).data;
|
const alarmInfoURL = `http://www.nmc.cn/rest/findAlarm?pageNo=1&pageSize=20&signaltype=&signallevel=&province=${province}`;
|
||||||
const $ = cheerio.load(html);
|
const response = await got({
|
||||||
const alarmElements = $('.alarmlist > div:not(.pagination)').toArray();
|
method: 'get',
|
||||||
|
url: alarmInfoURL,
|
||||||
|
});
|
||||||
|
const data = response.data.data;
|
||||||
|
const list = data.page.list;
|
||||||
|
|
||||||
ctx.state.data = {
|
ctx.state.data = {
|
||||||
title: '中央气象台全国气象预警',
|
title: '中央气象台全国气象预警',
|
||||||
link: alarmInfoURL,
|
link: `http://www.nmc.cn/publish/alarm.html`,
|
||||||
item: alarmElements.map((el) => {
|
item: list.map((item) => {
|
||||||
const $el = $(el);
|
const title = item.title;
|
||||||
const $aEl = $el.find('a');
|
const url = item.url;
|
||||||
return {
|
return {
|
||||||
title: $aEl.text(),
|
title: `${title}`,
|
||||||
link: `http://www.nmc.cn${$aEl.attr('href')}`,
|
link: `http://www.nmc.cn${url}`,
|
||||||
pubDate: date($el.find('.date').text(), 8),
|
pubDate: `${item.issuetime}`,
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user