我有两个问题,我正在使用 openweathermap 来预测某些城市的天气,但我没有得到下一个 dt 响应,而是我得到了 15:00

问题描述 投票:0回答:0

我在写一个小天气程序。我正在使用 openweathermap 获取一天中特定时间的天气预报。当我运行程序以获取当前天气时,响应似乎是正确和准确的。我使用这个链接:

http://api.openweathermap.org/data/2.5/weather?units=imperial&appid=XXXX&q=53201,US& 我明白了:

这对我的目的来说很好,但是当我试图了解天气时……假设在 13:00,我一直得到不正确的数据。

url = f"http://api.openweathermap.org/data/2.5/forecast?units=imperial&appid={API_key}&q={zipList[link]},US&dt={unix_ready[link]}&"

首先我没有得到下一个 dt 时间,我一直得到 15:00,其次......我注意到这个预测每 3 小时运行一次。有没有办法在 13:00 等更具体的时间请求时间?谢谢

当前天气反应(很好)

{“坐标”:{“lon”:-87.9225,“lat”:43.035},“天气”:[{“id”:804,“main”:“云”,“描述”:“阴云”, "icon":"04d"}],"base":"stations","main":{"temp":52.77,"feels_like":49.73,"temp_min":48.72,"temp_max":55.29,"pressure" :1009,“湿度”:42},“能见度”:10000,“风”:{“速度”:8.05,“度”:200},“云”:{“所有”:100},“dt”: 1680535853,"sys":{"type":2,"id":2081761,"country":"US","sunrise":1680521426,"sunset":1680567554},"timezone":-18000,"id" :5263045,"名称":"密尔沃基","鳕鱼":200}

预测响应:

{“cod”:“200”,“message”:0,“cnt”:40,“list”:[{“dt”:1680534000,“main”:{“temp”:52,“feels_like”:50.14 "temp_min":52,"temp_max":58.91,"pressure":1006,"sea_level":1006,"grnd_level":994,"humidity":69,"temp_kf":-3.84},"weather":[ {"id":804,"main":"Clouds","description":"阴云密布","icon":"04d"}],"clouds":{"all":100},"wind": {"speed":7.76,"deg":213,"gust":17.25},"visibility":10000,"pop":0.03,"sys":{"pod":"d"},"dt_txt" :"2023-04-03 15:00:00"},{"dt":1680544800,"main":{"temp":55.72,"feels_like":54.28,"temp_min":55.72,"temp_max": 63.16,“压力”:1008,“sea_level”:1008,“grnd_level”:993,“湿度”:70,“temp_kf”:-4.13},“天气”:[{“id”:500,“main”: "Rain","description":"小雨","icon":"10d"}],"clouds":{"all":99},"wind":{"speed":7.76,"deg": 217,"gust":16.49},"visibility":10000,"pop":0.24,"rain":{"3h":0.17},"sys":{"pod":"d"},"dt_txt" :"2023-04-03 18:00:00"},{"dt":1680555600,"main":

python openweathermap weather-api
© www.soinside.com 2019 - 2024. All rights reserved.