【发布时间】:2018-01-11 14:28:00
【问题描述】:
使用 openweathermap api 如何使用 javascript 获取某一天的平均温度。我知道我只能在接下来的 5 天内相处。我一直在寻找,但找不到方法,也没有看到其他人这样做。
【问题讨论】:
使用 openweathermap api 如何使用 javascript 获取某一天的平均温度。我知道我只能在接下来的 5 天内相处。我一直在寻找,但找不到方法,也没有看到其他人这样做。
【问题讨论】:
您可以使用 api api.openweathermap.org/data/2.5/forecast?q={city name},{country code}。详情请参考here。
您可以按城市名称搜索 5 天的天气预报,每 3 小时提供一次数据。所有天气数据都可以JSON和XML格式获取。
https://openweathermap.org/forecast5
API 调用:
api.openweathermap.org/data/2.5/forecast?q={city name},{country code}参数:
q 城市名称和国家代码以逗号分隔,使用 ISO 3166 国家 代码
API 调用示例:
api.openweathermap.org/data/2.5/forecast?q=London,us&mode=xml
【讨论】:
如果你使用免费模式,你可以使用API this>https://api.openweathermap.org/data/2.5/onecall?lat={lat}&lon={lon}&exclude={part}&appid={APIkey}
对于“排除”,值为“当前”
您可以在结果中找到“每日”
{"dt":1616238000,"temp":301.64,"feels_like":305.49,"pressure":1006,"湿度":72,"dew_point":296.11,"uvi":0.17,"clouds": 97,"visibility":10000,"wind_speed":1.94,"wind_deg":25,"wind_gust":4.14,"weather":[{"id":804,"main":"Clouds","description": "阴云","icon":"04d"}],"pop":0.39}],"daily":[{"dt":1616043600,"sunrise":1616023825,"sunset ":1616067395,"temp":{"day":305.68,"min":296.48,"max":305.68,"night":298.13,"eve":301.4,"morn":296.48},"feels_like": {"day":309.22,"night":302.32,"eve":306.11,"morn":300.23},"压力":1010,"湿度":55,"dew_point":295.34,"wind_speed":1.88, "wind_deg":2,"weather":[{"id":500,"main":"Rain","description":"小雨","icon":"10d"}],"clouds":71 ,"pop":0.58,"rain":1.88,"uvi":14.19},{"dt":1616130000,"sunrise":1616110201,"sunset":1616153783,"temp":{"day":305.38, "min":296.44,"max":305.62,"night":298.19,"eve":301.52,"morn":296.44},"feels_like":{"day":308.32,"night":302.18,"eve ":306.01,"早上":300.25},"压力":1010,"湿度":54,"露点":2 94.93,"wind_speed":2.3,"wind_deg":347,"weather":[{"id":501,"main":"Rain","description":"中雨","icon":"10d" }],"clouds":5,"pop":0.94,"rain":4.71,"uvi":13.78},{"dt":1616216400,"sunrise":1616196576,"sunset":1616240170,"temp" :{"day":305.82,"min":296.51,"max":306.34,"night":298.41,"eve":301.64,"morn":296.51},"feels_like":{"day":308.58, “夜晚”:302.5,“前夕”:305.49,“早晨”:300.44},“压力”:1009,“湿度”:51,“露点”:294.26,“风速”:2.17,“风度”:349,天气":[{"id":500,"main":"Rain","description":"小雨","icon":"10d"}],"clouds":93,"pop":0.4, "rain":0.23,"uvi":13.37},{"dt":1616302800,"sunrise":1616282952,"sunset":1616326557,"temp":{"day":305.56,"min":297.1,"最大":305.56,"夜晚":298.4,"前夕":299.56,"早上":297.1},"feels_like":{"白天":308.74,"夜晚":303.18,"前夕":304.47,"早上" :300.75},"压力":1009,"湿度":55,"dew_point":295.3,"wind_speed":2.31,"wind_deg":339,"weather":[{"id":500,"main": "雨","description":"小雨","icon":"10d"}],"clouds":88,"pop":0.48,"rain":1.85,"uvi ":13.47},{"dt":1616389200,"sunrise":1616369327,"sunset":1616412945,"temp":{"day":306.08,"min":296.6,"max":306.08,"night" :298.56,"eve":299.63,"morn":296.6},"feels_like":{"day":309.2,"night":303.14,"eve":304.4,"morn":300.19},"pressure": 1010,"湿度":52,"dew_point":294.84,"wind_speed":2.07,"wind_deg":13,"weather":[{"id":500,"main":"Rain","description": "小雨","icon":"10d"}],"clouds":98,"pop":0.67,"rain":3.8,"uvi":14},{"dt":1616475600,"sunrise" :1616455702,"日落":1616499332,"temp":{"day":307.01,"min":296.67,"max":307.01,"night":298.42,"eve":299.71,"morn":296.79} ,"feels_like":{"day":310.15,"night":303.02,"eve":304.13,"morn":300.55},"压力":1009,"湿度":48,"dew_point":294.56," wind_speed":1.7,"wind_deg":21,"weather":[{"id":501,"main":"Rain","description":"中雨","icon":"10d"}], "clouds":87,"pop":0.94,"rain":11.17,"uvi":14},{"dt":1616562000,"sunrise":1616542078,"sunset":1616585719,"temp":{"白天":303.09,"分钟":297.35,"最大":304.92,"晚上":298.34,"前夕":299.46,"早上":297.35},"fe els_like":{"day":307.61,"night":303.41,"eve":303.92,"morn":301.36},"压力":1008,"湿度":71,"dew_point":297.08,"wind_speed" :1.94,"wind_deg":348,"weather":[{"id":501,"main":"Rain","description":"中雨","icon":"10d"}],"clouds ":94,"pop":1,"rain":14.31,"uvi":14},{"dt":1616648400,"sunrise":1616628453,"sunset":1616672106,"temp":{"day" :305.73,"min":296.37,"max":305.73,"night":298.53,"eve":299.48,"morn":296.37},"feels_like":{"day":309.24,"night":302.82 ,"eve":304.03,"morn":300.08},"压力":1008,"湿度":55,"dew_point":295.37,"wind_speed":1.96,"wind_deg":49,"weather":[{ "id":501,"main":"Rain","description":"中雨","icon":"10d"}],"clouds":49,"pop":1,"rain":17.92 "uvi":14}]}
【讨论】: