头OpenWeather过来,并让自己的API关键。
This URL有一个所有城市的列表。有多个条目。我发现谷歌搜索和打这个URL旧金山(5391959):
http://openweathermap.org/city/5391959?utm_source=openweathermap&utm_medium=widget&utm_campaign=html_old
...我从中提取的5391959
城市ID。
武装你的API密钥和城市的ID,您可以使用以下两条命令,让您的天气JSON格式:
$weather = Invoke-WebRequest -Uri 'api.openweathermap.org/data/2.5/weather?id=5391959&APPID=YOUR_API_KEY_HERE'
$weatherObject = $weather.Content | ConvertFrom-Json
$weatherObject # display to console
...它会给你一个对象,像这样:
coord : @{lon=-122.42; lat=37.77}
weather : {@{id=804; main=Clouds; description=overcast clouds; icon=04n}}
base : stations
main : @{temp=285.91; pressure=1017; humidity=93; temp_min=283.15; temp_max=288.15}
visibility : 16093
wind : @{speed=4.6; deg=240}
clouds : @{all=90}
dt : 1489134900
sys : @{type=1; id=226; message=0.1525; country=US; sunrise=1489156026; sunset=1489198372}
id : 5391959
name : San Francisco
cod : 200
OpenWeatherAPI呢?看到这里例如:http://www.powershelladmin.com/wiki/Get-Weather_cmdlet_for_PowerShell,_using_the_OpenWeatherMap_API –
谢谢。我知道这个网站,但我想使用内置功能。 – LaPhi