feat(route): add Shanghai weather alert#22087
Conversation
| text: content | ||
| .replaceAll(/<br\s*\/?>/gi, '\n') | ||
| .replaceAll(/<[^>]+>/g, '') |
Auto Review
|
|
Then how to reopen this PR ( |
|
Successfully generated as following: http://localhost:1200/soweather/warn - Success ✔️<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<title>上海天气预警</title>
<link>https://wx.soweather.com/wxapp/warn.jsp</link>
<atom:link href="http://localhost:1200/soweather/warn" rel="self" type="application/rss+xml"></atom:link>
<description>上海天气预警 - Powered by RSSHub</description>
<generator>RSSHub</generator>
<webMaster>contact@rsshub.app (RSSHub)</webMaster>
<language>zh-CN</language>
<lastBuildDate>Sun, 24 May 2026 14:17:46 GMT</lastBuildDate>
<ttl>5</ttl>
<item>
<title>【已解除】金山区气象台发布雷电黄色预警</title>
<description>解除时间:2026-05-24 18:05<br>【市预警发布中心】金山区气象台2026年05月24日13时00分发布:预计未来12小时内,本区大部分街镇将发生雷电活动,可能会造成雷电灾害事故,请注意防范。</description>
<link>https://wx.soweather.com/wxapp/warn.jsp#%E9%87%91%E5%B1%B1%E5%8C%BA-37039-(2026)1163</link>
<guid isPermaLink="false">金山区-37039-(2026)1163</guid>
<pubDate>Sun, 24 May 2026 05:00:00 GMT</pubDate>
<author>金山区气象台</author>
<enclosure url="https://wx.soweather.com/wxapp/images/icon/hff0736_30.png" type="image/jpeg"></enclosure>
<category>分区历史预警</category>
<category>金山区</category>
<category>雷电黄色</category>
<category>已解除</category>
</item>
<item>
<title>崇明区气象台发布大风蓝色预警</title>
<description>【市预警发布中心】崇明区气象台2026年05月24日07时29分发布:预计未来24小时内本区大部分乡镇将出现阵风6-7级,长江口区7-8级的大风,请注意防范大风对高空作业、水陆交通、设施农业等的不利影响。</description>
<link>https://wx.soweather.com/wxapp/warn.jsp#%E5%B4%87%E6%98%8E%E5%8C%BA-37032-(2026)1156</link>
<guid isPermaLink="false">崇明区-37032-(2026)1156</guid>
<pubDate>Sat, 23 May 2026 23:29:00 GMT</pubDate>
<author>崇明区气象台</author>
<enclosure url="https://wx.soweather.com/wxapp/images/icon/hff0736_17.png" type="image/jpeg"></enclosure>
<category>分区预警</category>
<category>崇明区</category>
<category>大风蓝色</category>
<category>生效中</category>
</item>
<item>
<title>【已解除】奉贤区气象台发布雷电黄色预警</title>
<description>解除时间:2026-05-24 18:03<br>【市预警发布中心】奉贤区气象台2026年05月24日07时02分发布:预计未来12小时内,本区大部地区将发生雷电活动,可能会造成雷电灾害事故,请注意防范。</description>
<link>https://wx.soweather.com/wxapp/warn.jsp#%E5%A5%89%E8%B4%A4%E5%8C%BA-37031-(2026)1155</link>
<guid isPermaLink="false">奉贤区-37031-(2026)1155</guid>
<pubDate>Sat, 23 May 2026 23:02:00 GMT</pubDate>
<author>奉贤区气象台</author>
<enclosure url="https://wx.soweather.com/wxapp/images/icon/hff0736_30.png" type="image/jpeg"></enclosure>
<category>分区历史预警</category>
<category>奉贤区</category>
<category>雷电黄色</category>
<category>已解除</category>
</item>
<item>
<title>【已解除】上海中心气象台发布雷电黄色预警</title>
<description>解除时间:2026-05-24 18:00<br>【市预警发布中心】上海中心气象台2026年05月24日07时00分发布:预计未来12小时内,全市将发生雷电活动,可能会造成雷电灾害事故,请注意防范。</description>
<link>https://wx.soweather.com/wxapp/warn.jsp#%E5%85%A8%E5%B8%82-37028-(2026)1151</link>
<guid isPermaLink="false">全市-37028-(2026)1151</guid>
<pubDate>Sat, 23 May 2026 23:00:00 GMT</pubDate>
<author>上海中心气象台</author>
<enclosure url="https://wx.soweather.com/wxapp/images/icon/hff0736_30.png" type="image/jpeg"></enclosure>
<category>市级历史预警</category>
<category>全市</category>
<category>雷电黄色</category>
<category>已解除</category>
</item>
<item>
<title>【已解除】崇明区气象台发布雷电黄色预警</title>
<description>解除时间:2026-05-24 18:03<br>【市预警发布中心】崇明区气象台2026年05月24日07时00分发布:预计未来12小时内本区大部分乡镇将发生雷电活动,可能会造成雷电灾害事故,请注意防范。</description>
<link>https://wx.soweather.com/wxapp/warn.jsp#%E5%B4%87%E6%98%8E%E5%8C%BA-37030-(2026)1154</link>
<guid isPermaLink="false">崇明区-37030-(2026)1154</guid>
<pubDate>Sat, 23 May 2026 23:00:00 GMT</pubDate>
<author>崇明区气象台</author>
<enclosure url="https://wx.soweather.com/wxapp/images/icon/hff0736_30.png" type="image/jpeg"></enclosure>
<category>分区历史预警</category>
<category>崇明区</category>
<category>雷电黄色</category>
<category>已解除</category>
</item>
<item>
<title>【已解除】松江区气象台发布雷电黄色预警</title>
<description>解除时间:2026-05-24 18:03<br>【市预警发布中心】松江区气象台2026年05月24日04时26分发布:预计今天上午以前,本区大部分街镇将发生雷电活动,可能会造成雷电灾害事故,请注意防范。</description>
<link>https://wx.soweather.com/wxapp/warn.jsp#%E6%9D%BE%E6%B1%9F%E5%8C%BA-37026-(2026)1150</link>
<guid isPermaLink="false">松江区-37026-(2026)1150</guid>
<pubDate>Sat, 23 May 2026 20:26:00 GMT</pubDate>
<author>松江区气象台</author>
<enclosure url="https://wx.soweather.com/wxapp/images/icon/hff0736_30.png" type="image/jpeg"></enclosure>
<category>分区历史预警</category>
<category>松江区</category>
<category>雷电黄色</category>
<category>已解除</category>
</item>
<item>
<title>【已解除】嘉定区气象台发布雷电黄色预警</title>
<description>解除时间:2026-05-24 18:06<br>【市预警发布中心】嘉定区气象台2026年05月24日02时45分发布:预计今天上午以前,我区大部街镇将发生雷电活动,可能会造成雷电灾害事故,请注意防范。</description>
<link>https://wx.soweather.com/wxapp/warn.jsp#%E5%98%89%E5%AE%9A%E5%8C%BA-37023-(2026)1147</link>
<guid isPermaLink="false">嘉定区-37023-(2026)1147</guid>
<pubDate>Sat, 23 May 2026 18:45:00 GMT</pubDate>
<author>嘉定区气象台</author>
<enclosure url="https://wx.soweather.com/wxapp/images/icon/hff0736_30.png" type="image/jpeg"></enclosure>
<category>分区历史预警</category>
<category>嘉定区</category>
<category>雷电黄色</category>
<category>已解除</category>
</item>
<item>
<title>【已解除】上海中心气象台发布大风蓝色预警</title>
<description>解除时间:2026-05-18 18:00<br>【市预警发布中心】上海中心气象台2026年05月18日08时50分发布:预计未来24小时内,全市将出现阵风8级或平均风力6级以上的大风,请注意防范大风对高空作业、交通出行、设施农业等的不利影响。</description>
<link>https://wx.soweather.com/wxapp/warn.jsp#%E5%85%A8%E5%B8%82-36994-(2026)1116</link>
<guid isPermaLink="false">全市-36994-(2026)1116</guid>
<pubDate>Mon, 18 May 2026 00:50:00 GMT</pubDate>
<author>上海中心气象台</author>
<enclosure url="https://wx.soweather.com/wxapp/images/icon/hff0736_17.png" type="image/jpeg"></enclosure>
<category>市级历史预警</category>
<category>全市</category>
<category>大风蓝色</category>
<category>已解除</category>
</item>
<item>
<title>【已解除】上海中心气象台发布雷电黄色预警</title>
<description>解除时间:2026-04-16 20:43<br>【市预警发布中心】上海中心气象台2026年04月16日15时52分发布:预计今天半夜以前,全市将发生雷电活动,可能会造成雷电灾害事故,请注意防范。</description>
<link>https://wx.soweather.com/wxapp/warn.jsp#%E5%85%A8%E5%B8%82-36873-(2026)995</link>
<guid isPermaLink="false">全市-36873-(2026)995</guid>
<pubDate>Thu, 16 Apr 2026 07:52:00 GMT</pubDate>
<author>上海中心气象台</author>
<enclosure url="https://wx.soweather.com/wxapp/images/icon/hff0736_30.png" type="image/jpeg"></enclosure>
<category>市级历史预警</category>
<category>全市</category>
<category>雷电黄色</category>
<category>已解除</category>
</item>
<item>
<title>【已解除】上海中心气象台发布雷电黄色预警</title>
<description>解除时间:2026-04-10 06:15<br>【市预警发布中心】上海中心气象台2026年04月09日18时45分发布:预计今天半夜以前,全市将发生雷电活动,可能会造成雷电灾害事故,请注意防范。</description>
<link>https://wx.soweather.com/wxapp/warn.jsp#%E5%85%A8%E5%B8%82-36831-(2026)953</link>
<guid isPermaLink="false">全市-36831-(2026)953</guid>
<pubDate>Thu, 09 Apr 2026 10:45:00 GMT</pubDate>
<author>上海中心气象台</author>
<enclosure url="https://wx.soweather.com/wxapp/images/icon/hff0736_30.png" type="image/jpeg"></enclosure>
<category>市级历史预警</category>
<category>全市</category>
<category>雷电黄色</category>
<category>已解除</category>
</item>
<item>
<title>【已解除】上海中心气象台发布大风蓝色预警</title>
<description>解除时间:2026-04-09 10:20<br>【市预警发布中心】上海中心气象台2026年04月08日15时25分发布:预计未来24小时内,本市陆地最大阵风7-8级,沿江沿海地区8-9级,请注意防范大风对高空作业、交通出行、设施农业等的不利影响。</description>
<link>https://wx.soweather.com/wxapp/warn.jsp#%E5%85%A8%E5%B8%82-36797-(2026)919</link>
<guid isPermaLink="false">全市-36797-(2026)919</guid>
<pubDate>Wed, 08 Apr 2026 07:25:00 GMT</pubDate>
<author>上海中心气象台</author>
<enclosure url="https://wx.soweather.com/wxapp/images/icon/hff0736_17.png" type="image/jpeg"></enclosure>
<category>市级历史预警</category>
<category>全市</category>
<category>大风蓝色</category>
<category>已解除</category>
</item>
</channel>
</rss> |
| } | ||
|
|
||
| async function handler(): Promise<Data | null> { | ||
| const response = await cache.tryGet(`soweather:warn:${dataUrl}`, () => ofetch<string>(dataUrl, { parseResponse: (txt) => txt }), cacheMaxAge); |
There was a problem hiding this comment.
Do not hardcode the cache duration. Users are expected to adjust it to their liking thru envs.
There was a problem hiding this comment.
Do not hardcode the cache duration. Users are expected to adjust it to their liking thru envs.
cuz the Shanghai Weather Station does not publish the alerts in fixed intervals, and the global duration setting might be too long for a weather alert, but should be fine for other feeds like news or daily weather forecast ( and also the env since you can't configure it for each route ) , so I hardcoded this as I tested it to be a sweet point for cache duration.
Or if it's should be left to the users to consider about this, I would remove the param later.
There was a problem hiding this comment.
It's up to the users to decide where the sweet spot is for them. I know some have set the cache duration to 0 so they get fresh content every time their RSS reader updates.
Involved Issue / 该 PR 相关 Issue
Close #
Example for the Proposed Route(s) / 路由地址示例
New RSS Route Checklist / 新 RSS 路由检查表
PuppeteerNote / 说明