javascript - OpenWeatherMap 获取当日平均气温

标签 javascript openweathermap

使用 openweathermap api,如何使用 javascript 获取某一天的平均温度。我知道我的能力有限,只能在接下来的 5 天内完成。我一直在寻找,但找不到一种方法来做到这一点,也没有看到其他人这样做。

最佳答案

您可以使用 API api.openweathermap.org/data/2.5/forecast?q={city name},{country code}。请引用here了解更多详情。

您可以按城市名称搜索每 3 小时一次的 5 天天气预报。所有天气数据都可以JSON和XML格式获取。

https://openweathermap.org/forecast5

API call:

api.openweathermap.org/data/2.5/forecast?q={city name},{country code}

Parameters:

q city name and country code divided by comma, use ISO 3166 country codes

Examples of API calls:

api.openweathermap.org/data/2.5/forecast?q=London,us&mode=xml

关于javascript - OpenWeatherMap 获取当日平均气温,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45493426/

相关文章:

javascript - 如何在 ProtoType 中使用 Promises *around* 回调进行方法链接

javascript - onclick 向 div 添加文本

javascript - 检查了无数次都无法弄清楚我的错误在哪里 : Uncaught TypeError: Cannot read properties of undefined (reading 'lat' )

javascript - 分机JS : How to pass geolocation values to url?

api-key - 公开免费的 API key 有哪些风险?

javascript - 如何在调用 JQUERY 中使用的 css 和 html 函数之前调用 hook?

javascript - 页面第二次加载时无法显示加载微调图像

javascript - React - 使用用户输入进行 API 调用的正确方法是什么?

swift - 如何从 OpenWeatherMap 解析 "Rain"?

javascript - 如何有效调试动画代码