@Grab(group='org.jsoup', module='jsoup', version='1.6.1') import org.jsoup.* import org.jsoup.select.* // 都市名を指定して天気情報を取得 cityname = "Tokyo" doc = Jsoup.connect("http://www.google.com/ig/api?hl=ja&weather=${cityname}").get() // 天気を表示 for(elem in Selector.select("current_conditions condition", doc)){ println(elem.attr("data")) } // 温度を表示 for(elem in Selector.select("current_conditions temp_c", doc)){ println(elem.attr("data")) } // 湿度を表示 for(elem in Selector.select("current_conditions humidity", doc)){ println(elem.attr("data")) } // 風向きを表示 for(elem in Selector.select("current_conditions wind_condition", doc)){ println(elem.attr("data")) }
動作環境
groovy 1.8.2, JDK6 Update27, jsoup 1.6.1
0 件のコメント:
コメントを投稿