mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-06 13:08:14 +08:00
feature: ceic (#2524)
* Fix the scripts run in Windows * Feature: 中国地震台 * 添加item数量限制 * 添加类型检查 * Add doc * Revert
This commit is contained in:
@@ -4,6 +4,24 @@ pageClass: routes
|
|||||||
|
|
||||||
# 预报预警
|
# 预报预警
|
||||||
|
|
||||||
|
## 地震速报
|
||||||
|
|
||||||
|
### 中国地震局
|
||||||
|
|
||||||
|
<Route author="LogicJake" example="/earthquake" path="/earthquake/:region?" :paramsDesc="['区域,0全部,1国内(默认),2国外']" crawlerBadge="1">
|
||||||
|
|
||||||
|
可通过全局过滤参数订阅您感兴趣的地区.
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
|
||||||
|
### 中国地震台
|
||||||
|
|
||||||
|
<Route author="SettingDust" example="/earthquake/ceic/1" path="/earthquake/ceic/:type" :paramsDesc="['类型,1 最近24小时地震信息, 2: 最近48小时地震信息, 5: 最近一年3.0级以上地震信息, 7: 最近一年3.0级以下地震, 8: 最近一年4.0级以上地震信息, 9: 最近一年5.0级以上地震信息, 0: 最近一年6.0级以上地震信息']">
|
||||||
|
|
||||||
|
可通过全局过滤参数订阅您感兴趣的地区.
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
|
||||||
## 停电通知
|
## 停电通知
|
||||||
|
|
||||||
获取未来一天的停电通知
|
获取未来一天的停电通知
|
||||||
@@ -70,16 +88,6 @@ pageClass: routes
|
|||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
## 中国地震局
|
|
||||||
|
|
||||||
### 地震速报
|
|
||||||
|
|
||||||
<Route author="LogicJake" example="/earthquake" path="/earthquake/:region?" :paramsDesc="['区域,0全部,1国内(默认),2国外']" crawlerBadge="1">
|
|
||||||
|
|
||||||
可通过全局过滤参数订阅您感兴趣的地区.
|
|
||||||
|
|
||||||
</Route>
|
|
||||||
|
|
||||||
## 中央气象台
|
## 中央气象台
|
||||||
|
|
||||||
### 全国气象预警
|
### 全国气象预警
|
||||||
|
|||||||
@@ -484,6 +484,9 @@ router.get('/mafengwo/note/:type', require('./routes/mafengwo/note'));
|
|||||||
// 中国地震局震情速递(与地震台网同步更新)
|
// 中国地震局震情速递(与地震台网同步更新)
|
||||||
router.get('/earthquake/:region?', require('./routes/earthquake'));
|
router.get('/earthquake/:region?', require('./routes/earthquake'));
|
||||||
|
|
||||||
|
// 中国地震台网
|
||||||
|
router.get('/earthquake/ceic/:type', require('./routes/earthquake/ceic'));
|
||||||
|
|
||||||
// 笔趣阁
|
// 笔趣阁
|
||||||
router.get('/biquge/novel/latestchapter/:id', require('./routes/novel/biquge'));
|
router.get('/biquge/novel/latestchapter/:id', require('./routes/novel/biquge'));
|
||||||
|
|
||||||
|
|||||||
65
lib/routes/earthquake/ceic.js
Normal file
65
lib/routes/earthquake/ceic.js
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
let type = Number(ctx.params.type);
|
||||||
|
type = type ? type : 1;
|
||||||
|
const baseUrl = 'http://www.ceic.ac.cn';
|
||||||
|
const api = `${baseUrl}/ajax/speedsearch?num=${type}`;
|
||||||
|
const mappings = {
|
||||||
|
O_TIME: '发震时刻(UTC+8)',
|
||||||
|
LOCATION_C: '参考位置',
|
||||||
|
M: '震级(M)',
|
||||||
|
EPI_LAT: '纬度(°)',
|
||||||
|
EPI_LON: '经度(°)',
|
||||||
|
EPI_DEPTH: '深度(千米)',
|
||||||
|
SAVE_TIME: '录入时间',
|
||||||
|
};
|
||||||
|
|
||||||
|
const typeMappings = {
|
||||||
|
1: '最近24小时地震信息',
|
||||||
|
2: '最近48小时地震信息',
|
||||||
|
3: '最近7天地震信息',
|
||||||
|
4: '最近30天地震信息',
|
||||||
|
5: '最近一年3.0级以上地震信息',
|
||||||
|
6: '最近一年地震信息',
|
||||||
|
7: '最近一年3.0级以下地震',
|
||||||
|
8: '最近一年4.0级以上地震信息',
|
||||||
|
9: '最近一年5.0级以上地震信息',
|
||||||
|
0: '最近一年6.0级以上地震信息',
|
||||||
|
};
|
||||||
|
|
||||||
|
// 因为item数量限制20,所以对于RSS来说为无用类型,防止浪费资源
|
||||||
|
const disabledType = [3, 4, 6];
|
||||||
|
|
||||||
|
if (disabledType.includes(type)) {
|
||||||
|
type = 1;
|
||||||
|
}
|
||||||
|
const typeName = typeMappings[type];
|
||||||
|
|
||||||
|
const response = await got(api);
|
||||||
|
const data = response.data;
|
||||||
|
let json = JSON.parse(data.substring(1, data.length - 1)).shuju;
|
||||||
|
if (json.length > 20) {
|
||||||
|
json = json.slice(0, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: typeName,
|
||||||
|
link: `${baseUrl}/speedsearch`,
|
||||||
|
item: json.map((entity) => {
|
||||||
|
const contentBuilder = [];
|
||||||
|
const { NEW_DID } = entity;
|
||||||
|
for (const mappingsKey in mappings) {
|
||||||
|
contentBuilder.push(`${mappings[mappingsKey]} ${entity[mappingsKey]}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
title: `${entity.LOCATION_C}发生${entity.M}级地震`,
|
||||||
|
link: `${baseUrl}/${NEW_DID}.html`,
|
||||||
|
pubDate: new Date(entity.O_TIME).toUTCString(),
|
||||||
|
description: contentBuilder.join('<br>'),
|
||||||
|
guid: NEW_DID,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -19,13 +19,9 @@ module.exports = async (ctx) => {
|
|||||||
|
|
||||||
const out = await Promise.all(
|
const out = await Promise.all(
|
||||||
data.map(async (item) => {
|
data.map(async (item) => {
|
||||||
const id = item.id;
|
const { id, epicenter, latitudes, longitudes, depth } = item;
|
||||||
const epicenter = item.epicenter;
|
|
||||||
const date = item.orig_time.slice(0, -2);
|
const date = item.orig_time.slice(0, -2);
|
||||||
const num = item.num_mag;
|
const num = item.num_mag;
|
||||||
const latitudes = item.latitudes;
|
|
||||||
const longitudes = item.longitudes;
|
|
||||||
const depth = item.depth;
|
|
||||||
|
|
||||||
const description = `北京时间${date},${epicenter}(纬度${latitudes}度,经度${longitudes}度)发生${num}级地震,震源深度${depth}千米`;
|
const description = `北京时间${date},${epicenter}(纬度${latitudes}度,经度${longitudes}度)发生${num}级地震,震源深度${depth}千米`;
|
||||||
const single = {
|
const single = {
|
||||||
|
|||||||
@@ -118,4 +118,4 @@
|
|||||||
"_moduleAliases": {
|
"_moduleAliases": {
|
||||||
"@": "./lib"
|
"@": "./lib"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user