feat(route): add 国家气候中心最新监测 (#14151)
* feat(route): add 国家气候中心最新监测 * fix typo
This commit is contained in:
parent
f20bca610f
commit
7a259bf494
|
|
@ -0,0 +1,81 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
const iconv = require('iconv-lite');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { id } = ctx.params;
|
||||
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 50;
|
||||
|
||||
const ids = id?.split(/\//) ?? [];
|
||||
const titles = [];
|
||||
|
||||
const rootUrl = 'http://cmdp.ncc-cma.net';
|
||||
const currentUrl = new URL('cn/index.htm', rootUrl).href;
|
||||
|
||||
const { data: response } = await got(currentUrl, {
|
||||
responseType: 'buffer',
|
||||
});
|
||||
|
||||
const $ = cheerio.load(iconv.decode(response, 'gbk'));
|
||||
|
||||
const author = '国家气候中心';
|
||||
|
||||
const items = $('ul.img-con-new-con li img[id]')
|
||||
.toArray()
|
||||
.filter((item) => ids.length === 0 || ids.includes($(item).prop('id')))
|
||||
.slice(0, limit)
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
|
||||
const id = item.prop('id');
|
||||
const title = $(`li[data-id="${id}"]`).text() || undefined;
|
||||
const src = new URL(item.prop('src'), currentUrl).href;
|
||||
const date =
|
||||
src
|
||||
.match(/_(\d{4})(\d{2})(\d{2})_/)
|
||||
?.slice(1, 4)
|
||||
.join('-') ?? new Date().toISOString().slice(0, 10);
|
||||
|
||||
if (ids.length !== 0 && title) {
|
||||
titles.push(title);
|
||||
}
|
||||
|
||||
return {
|
||||
title: `${title} ${date}`,
|
||||
link: currentUrl,
|
||||
description: art(path.join(__dirname, 'templates/description.art'), {
|
||||
image: {
|
||||
src,
|
||||
alt: `${title} ${date}`,
|
||||
},
|
||||
}),
|
||||
author,
|
||||
category: [title],
|
||||
guid: `ncc-cma#${id}#${date}`,
|
||||
pubDate: parseDate(date),
|
||||
enclosure_url: src,
|
||||
enclosure_type: `image/${src.split(/\./).pop()}`,
|
||||
};
|
||||
});
|
||||
|
||||
const subtitle = $('h1').last().text();
|
||||
const image = $('img.logo').prop('src');
|
||||
const icon = new URL('favicon.ico', rootUrl).href;
|
||||
|
||||
ctx.state.data = {
|
||||
item: items,
|
||||
title: `${author} - ${subtitle}${titles.length === 0 ? '' : ` - ${titles.join('|')}`}`,
|
||||
link: currentUrl,
|
||||
description: $('title').text(),
|
||||
language: 'zh',
|
||||
image,
|
||||
icon,
|
||||
logo: icon,
|
||||
subtitle,
|
||||
author,
|
||||
allowEmpty: true,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/cmdp/image/:id?': ['nczitzk'],
|
||||
};
|
||||
|
|
@ -0,0 +1,229 @@
|
|||
module.exports = {
|
||||
'ncc-cma.net': {
|
||||
_name: '国家气候中心',
|
||||
cmdp: [
|
||||
{
|
||||
title: '中国气温 - 日平均气温距平',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/RPJQWQYZ',
|
||||
},
|
||||
{
|
||||
title: '中国气温 - 近5天平均气温距平',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/ZJ5TPJQWJP',
|
||||
},
|
||||
{
|
||||
title: '中国气温 - 近10天平均气温距平',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/ZJ10TQWJP',
|
||||
},
|
||||
{
|
||||
title: '中国气温 - 近20天平均气温距平',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/ZJ20TQWJP',
|
||||
},
|
||||
{
|
||||
title: '中国气温 - 近30天平均气温距平',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/ZJ30TQWJP',
|
||||
},
|
||||
{
|
||||
title: '中国气温 - 本月以来气温距平',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/BYYLQWJP',
|
||||
},
|
||||
{
|
||||
title: '中国气温 - 本季以来气温距平',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/BJYLQWJP',
|
||||
},
|
||||
{
|
||||
title: '中国气温 - 本年以来气温距平',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/BNYLQWJP',
|
||||
},
|
||||
{
|
||||
title: '中国降水 - 日降水量分布',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/QGRJSLFBT0808S',
|
||||
},
|
||||
{
|
||||
title: '中国降水 - 近5天降水量',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/ZJ5TJSLFBT',
|
||||
},
|
||||
{
|
||||
title: '中国降水 - 近10天降水量',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/ZJ10TJSL',
|
||||
},
|
||||
{
|
||||
title: '中国降水 - 近20天降水量',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/ZJ20TJSL',
|
||||
},
|
||||
{
|
||||
title: '中国降水 - 近30天降水量',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/ZJ30TJSL',
|
||||
},
|
||||
{
|
||||
title: '中国降水 - 本月以来降水量',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/BYYLJSL',
|
||||
},
|
||||
{
|
||||
title: '中国降水 - 本季以来降水量',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/BJYLJSL',
|
||||
},
|
||||
{
|
||||
title: '中国降水 - 近10天降水量距平百分率',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/ZJ10TJSLJP',
|
||||
},
|
||||
{
|
||||
title: '中国降水 - 近20天降水量距平百分率',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/ZJ20TJSLJP',
|
||||
},
|
||||
{
|
||||
title: '中国降水 - 近30天降水量距平百分率',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/ZJ30TJSLJP',
|
||||
},
|
||||
{
|
||||
title: '中国降水 - 本月以来降水量距平百分率',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/BYYLJSLJPZYQHZ',
|
||||
},
|
||||
{
|
||||
title: '中国降水 - 本季以来降水量距平百分率',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/BJYLJSLJPZJQHZ',
|
||||
},
|
||||
{
|
||||
title: '中国降水 - 本年以来降水量距平百分率',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/BNYLJSLJP',
|
||||
},
|
||||
{
|
||||
title: '全球气温 - 气温距平(最近10天)',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/glbtmeana10_',
|
||||
},
|
||||
{
|
||||
title: '全球气温 - 气温距平(最近20天)',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/glbtmeana20_',
|
||||
},
|
||||
{
|
||||
title: '全球气温 - 气温距平(最近30天)',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/glbtmeana30_',
|
||||
},
|
||||
{
|
||||
title: '全球气温 - 气温距平(最近90天)',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/glbtmeana90_',
|
||||
},
|
||||
{
|
||||
title: '全球气温 - 最低气温距平(最近30天)',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/glbtmina30_',
|
||||
},
|
||||
{
|
||||
title: '全球气温 - 最低气温距平(最近90天)',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/glbtmina90_',
|
||||
},
|
||||
{
|
||||
title: '全球气温 - 最高气温距平(最近30天)',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/glbtmaxa30_',
|
||||
},
|
||||
{
|
||||
title: '全球气温 - 最高气温距平(最近90天)',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/glbtmaxa90_',
|
||||
},
|
||||
{
|
||||
title: '全球降水 - 降水量(最近10天)',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/glbrain10_',
|
||||
},
|
||||
{
|
||||
title: '全球降水 - 降水量(最近20天)',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/glbrain20_',
|
||||
},
|
||||
{
|
||||
title: '全球降水 - 降水量(最近30天)',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/glbrain30_',
|
||||
},
|
||||
{
|
||||
title: '全球降水 - 降水量(最近90天)',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/glbrain90_',
|
||||
},
|
||||
{
|
||||
title: '全球降水 - 降水距平百分率(最近10天)',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/glbraina10_',
|
||||
},
|
||||
{
|
||||
title: '全球降水 - 降水距平百分率(最近20天)',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/glbraina20_',
|
||||
},
|
||||
{
|
||||
title: '全球降水 - 降水距平百分率(最近30天)',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/glbraina30_',
|
||||
},
|
||||
{
|
||||
title: '全球降水 - 降水距平百分率(最近90天)',
|
||||
docs: 'https://docs.rsshub.app/routes/forecast#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce',
|
||||
source: ['/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/glbraina90_',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/cmdp/image/:id*', require('./cmdp'));
|
||||
};
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
{{ if image?.src }}
|
||||
<figure>
|
||||
<img
|
||||
{{ if image.alt }}
|
||||
alt="{{ image.alt }}"
|
||||
{{ /if }}
|
||||
src="{{ image.src }}">
|
||||
</figure>
|
||||
{{ /if }}
|
||||
|
|
@ -68,6 +68,77 @@
|
|||
|
||||
<Route author="Fatpandac" example="/gov/guangdong/tqyb/sncsyjxh" path="/gov/guangdong/tqyb/sncsyjxh" />
|
||||
|
||||
## 国家气候中心 {#guo-jia-qi-hou-zhong-xin}
|
||||
|
||||
### 最新监测 {#guo-jia-qi-hou-zhong-xin-zui-xin-jian-ce}
|
||||
|
||||
<Route author="nczitzk" example="/ncc-cma/cmdp/image" path="/ncc-cma/cmdp/image" paramsDesc={['分类 id,见下表,默认为全部']} radar="1" supportBT="1">
|
||||
:::tip
|
||||
若订阅全部最新监测信息,此时路由为 [`/ncc-cma/cmdp/image`](https://rsshub.app/ncc-cma/cmdp/image)。
|
||||
|
||||
若订阅中国气温 **日平均气温距平** 的最新监测信息,此时路由为 [`/ncc-cma/cmdp/image/RPJQWQYZ`](https://rsshub.app/ncc-cma/cmdp/image/RPJQWQYZ)。
|
||||
|
||||
若订阅全球降水 **降水量(最近 10 天)** / **降水量(最近 10 天)** / **降水量(最近 10 天)** 的最新监测信息,此时路由为 [`/ncc-cma/cmdp/image/glbrain10_/glbrain20_/glbrain30_`](https://rsshub.app/ncc-cma/cmdp/image/glbrain10_/glbrain20_/glbrain30_)。
|
||||
:::
|
||||
|
||||
#### [中国气温](http://cmdp.ncc-cma.net/cn/index.htm)
|
||||
|
||||
| 分类 | ID |
|
||||
| -------------------- | ---------- |
|
||||
| 日平均气温距平 | RPJQWQYZ |
|
||||
| 近 5 天平均气温距平 | ZJ5TPJQWJP |
|
||||
| 近 10 天平均气温距平 | ZJ10TQWJP |
|
||||
| 近 20 天平均气温距平 | ZJ20TQWJP |
|
||||
| 近 30 天平均气温距平 | ZJ30TQWJP |
|
||||
| 本月以来气温距平 | BYYLQWJP |
|
||||
| 本季以来气温距平 | BJYLQWJP |
|
||||
| 本年以来气温距平 | BNYLQWJP |
|
||||
|
||||
#### [中国降水](http://cmdp.ncc-cma.net/cn/index.htm)
|
||||
|
||||
| 分类 | ID |
|
||||
| ------------------------ | -------------- |
|
||||
| 日降水量分布 | QGRJSLFBT0808S |
|
||||
| 近 5 天降水量 | ZJ5TJSLFBT |
|
||||
| 近 10 天降水量 | ZJ10TJSL |
|
||||
| 近 20 天降水量 | ZJ20TJSL |
|
||||
| 近 30 天降水量 | ZJ30TJSL |
|
||||
| 本月以来降水量 | BYYLJSL |
|
||||
| 本季以来降水量 | BJYLJSL |
|
||||
| 近 10 天降水量距平百分率 | ZJ10TJSLJP |
|
||||
| 近 20 天降水量距平百分率 | ZJ20TJSLJP |
|
||||
| 近 30 天降水量距平百分率 | ZJ30TJSLJP |
|
||||
| 本月以来降水量距平百分率 | BYYLJSLJPZYQHZ |
|
||||
| 本季以来降水量距平百分率 | BJYLJSLJPZJQHZ |
|
||||
| 本年以来降水量距平百分率 | BNYLJSLJP |
|
||||
|
||||
#### [全球气温](http://cmdp.ncc-cma.net/cn/index.htm)
|
||||
|
||||
| 分类 | ID |
|
||||
| -------------------------- | ------------- |
|
||||
| 气温距平(最近 10 天) | glbtmeana10\_ |
|
||||
| 气温距平(最近 20 天) | glbtmeana20\_ |
|
||||
| 气温距平(最近 30 天) | glbtmeana30\_ |
|
||||
| 气温距平(最近 90 天) | glbtmeana90\_ |
|
||||
| 最低气温距平(最近 30 天) | glbtmina30\_ |
|
||||
| 最低气温距平(最近 90 天) | glbtmina90\_ |
|
||||
| 最高气温距平(最近 30 天) | glbtmaxa30\_ |
|
||||
| 最高气温距平(最近 90 天) | glbtmaxa90\_ |
|
||||
|
||||
#### [全球降水](http://cmdp.ncc-cma.net/cn/index.htm)
|
||||
|
||||
| 分类 | ID |
|
||||
| ---------------------------- | ------------ |
|
||||
| 降水量(最近 10 天) | glbrain10\_ |
|
||||
| 降水量(最近 20 天) | glbrain20\_ |
|
||||
| 降水量(最近 30 天) | glbrain30\_ |
|
||||
| 降水量(最近 90 天) | glbrain90\_ |
|
||||
| 降水距平百分率(最近 10 天) | glbraina10\_ |
|
||||
| 降水距平百分率(最近 20 天) | glbraina20\_ |
|
||||
| 降水距平百分率(最近 30 天) | glbraina30\_ |
|
||||
| 降水距平百分率(最近 90 天) | glbraina90\_ |
|
||||
</Route>
|
||||
|
||||
## 国家突发事件预警信息发布网 {#guo-jia-tu-fa-shi-jian-yu-jing-xin-xi-fa-bu-wang}
|
||||
|
||||
### 当前生效预警 {#guo-jia-tu-fa-shi-jian-yu-jing-xin-xi-fa-bu-wang-dang-qian-sheng-xiao-yu-jing}
|
||||
|
|
|
|||
Loading…
Reference in New Issue