@Grab(group='org.jsoup', module='jsoup', version='1.6.1') import groovy.json.* // 各地域・各国の人口増加率を取得 yearFrom = "2010" yearTo = "2010" base = "http://api.worldbank.org/countries/all/indicators/SP.POP.GROW" param = "?per_page=1000&date=${yearFrom}:${yearTo}&format=json" result = "${base}${param}".toURL().text slurper = new JsonSlurper() json = slurper.parseText(result) for(elem in json[1]){ // 地域・国名 country = elem.country.value // 年 year = elem.date // 値 value = elem.value println("${country}:${year}:${value}") }
動作環境
groovy 1.8.2, JDK6 Update27, jsoup 1.6.1
0 件のコメント:
コメントを投稿