api.openweather
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了api.openweather相关的知识,希望对你有一定的参考价值。
1.从openweather获取开源天气信息的方法:
http://api.openweathermap.org/data/2.5/weather?q=London&appid=2233c2ce7363b83f8bc8c182f74316bc
获得的数据如下:
{
"coord":{"lon":-0.13,"lat":51.51},
"weather":[
{
"id":500,
"main":"Rain",
"description":"light rain",
"icon":"10n"
}
],
"base":"stations",
"main":{
"temp":284.705,
"pressure":1017.11,
"humidity":100,
"temp_min":284.705,
"temp_max":284.705,
"sea_level":1024.73,
"grnd_level":1017.11
},
"wind":{
"speed":3.21,
"deg":152.502
},
"rain":{"3h":1.91},
"clouds":{"all":92},
"dt":1476597192,
"sys":{
"message":0.0113,
"country":"GB",
"sunrise":1476599231,
"sunset":1476637427
},
"id":2643743,
"name":"London",
"cod":200
}
2.从openweather获取城市列表的方法:
http://api.openweathermap.org/data/2.5/find?q=London&appid=2233c2ce7363b83f8bc8c182f74316bc
{
"message":"accurate","cod":"200","count":4,
"list":[
{"id":1687801,"name":"Santiago","coord":{"lon":121.548698,"lat":16.68808},"main":{"temp":298.055,"temp_min":298.055,"temp_max":298.055,"pressure":995.55,"sea_level":1014.8,"grnd_level":995.55,"humidity":98},"dt":1476599537,"wind":{"speed":4.26,"deg":142.502},"sys":{"country":"PH"},"rain":{"3h":2.3},"clouds":{"all":88},"weather":[{"id":500,"main":"Rain","description":"light rain","icon":"10d"}]},
{"id":3449741,"name":"Santiago","coord":{"lon":-54.867222,"lat":-29.191669},"main":{"temp":295.405,"temp_min":295.405,"temp_max":295.405,"pressure":988.98,"sea_level":1018.33,"grnd_level":988.98,"humidity":92},"dt":1476599513,"wind":{"speed":6.71,"deg":358.502},"sys":{"country":"BR"},"clouds":{"all":44},"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03n"}]},
{"id":3871336,"name":"Santiago","coord":{"lon":-70.64827,"lat":-33.45694},"main":{"temp":281.83,"temp_min":281.83,"temp_max":281.83,"pressure":944.16,"sea_level":1025.46,"grnd_level":944.16,"humidity":95},"dt":1476599235,"wind":{"speed":1.26,"deg":15.5017},"sys":{"country":"CL"},"rain":{"3h":2.85},"clouds":{"all":88},"weather":[{"id":500,"main":"Rain","description":"light rain","icon":"10n"}]},
{"id":3983671,"name":"Santiago","coord":{"lon":-100.150002,"lat":25.41667},"main":{"temp":287.555,"temp_min":287.555,"temp_max":287.555,"pressure":852.31,"sea_level":1028.34,"grnd_level":852.31,"humidity":68},"dt":1476599537,"wind":{"speed":0.76,"deg":225.502},"sys":{"country":"MX"},"clouds":{"all":0},"weather":[{"id":800,"main":"Clear","description":"Sky is Clear","icon":"01n"}]}
]
}
以上是关于api.openweather的主要内容,如果未能解决你的问题,请参考以下文章