PowerShell覚え書き
背景
iGoogleのお天気ガジェットで使用している非公式のgoogle Weather APIがあるということで、使ってみました。とりあえず、メモしておきます。$location="東京都武蔵野市" $encoded_location=[System.Uri]::EscapeDataString($location) $google_weather_uri="http://www.google.com/ig/api?weather="+$encoded_location+"&hl=ja" $xml=[XML](New-Object System.Net.WebClient).DownloadString($google_weather_uri) "【場所】" $xml.xml_api_reply.weather.forecast_information.city.data "【現在】" $xml.xml_api_reply.weather.current_conditions| %{ "気温:"+$_.temp_c.data+"度 "+$_.humidity.data+" "+$_.wind_condition.data+" 天気:"+$_.condition.data } "【予報】" $xml.xml_api_reply.weather.forecast_conditions| %{ $_.day_of_week.data+"曜日 気温:"+$_.low.data+"度~"+$_.high.data+"度 天気:"+$_.condition.data }
実行結果
【場所】Musashino, Tokyo
【現在】
気温:16度 湿度 : 88% 風: 北 10 m/s 天気:弱い雨
【予報】
火曜日 気温:15度~22度 天気:雨
水曜日 気温:16度~24度 天気:雨の可能性
木曜日 気温:16度~24度 天気:ところにより晴れ
金曜日 気温:16度~26度 天気:ところにより晴れ
iGoogleのサービスが2013年10月末までとなったので、おそらくこのAPIも停止されるでしょう。
返信削除