We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
有许多天气 API 可以根据邮政编码查找天气,或者找到最近的邮政编码。请参阅此问题。
国家气象局有一个 REST API。 CTRL+F 获取邮政编码:
这是一个请求示例
我不确定该请求是否符合当前条件。如果没有,您可以使用 Wunderground API。首先,您使用 GeolookupXML 根据城市查找附近的气象站(请参阅示例输出中的
nearby_weather_stations
元素),然后您可以使用 WXCurrentObXML 获取气象站之一的状况。There are numerous weather APIs out there that will look up the weather based on zip codes, or find the nearest one for a zip code. See this question.
The national weather service has a REST API. CTRL+F for zipcode:
Here is a sample request
I'm not sure if that one has current conditions. If not, you can use the Wunderground API. First you use GeolookupXML to look up nearby weather stations based on the city (see the
nearby_weather_stations
element in the sample output), then you can use WXCurrentObXML to get the conditions at one of the weather stations.虽然需要进行一些搜索,但 NOAA 维护了所有 METAR 气象站的列表,其中包含它们的纬度和经度坐标,以及指向它们的 RSS 和 XML 提要 URL 的直接链接。该列表以 XML 形式存储在此处: http://www.weather.gov/xml/current_obs /index.xml
您可以使用 Google 或 Yahoo 的地理编码 API 来查找地名的纬度/经度(城市、地址、邮政编码等),然后在气象站列表中搜索距离该地点最近的 METAR 站给定位置。
It took some searching, but NOAA maintains a list of all the METAR weather stations, with their latitude and longitude coordinates, as well as direct links to their RSS and XML feed URLs. The list is stored in XML here: http://www.weather.gov/xml/current_obs/index.xml
You could use Google's or Yahoo's geocoding APIs to lookup the latitude/longitude of a place name (City, Address, Zipcode, etc.) and then search the weather stations list for the closest METAR station to the given location.
我尝试了您的链接,但街道输入了我的邮政编码,而不是城市。它返回了正确的位置和天气预报。它可能只是一个记录不充分的 API,并且用 5 位 zip 替换的城市/街道参数确实可以满足您的要求。
i tried your link and instead of City, Street inputed my zip code. It returned the correct location and weather report. It's possible that it's just a poorly-documented API and a city/street parameter replaced with a 5-digit zip will indeed do what you want.