Last active
September 16, 2015 15:37
-
-
Save matthallamew/25bbd0bda159ed84b59c to your computer and use it in GitHub Desktop.
Simple Groovy script to get current temperature from the command line using the Wunderground API.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env groovy | |
import groovy.json.JsonSlurper; | |
String STATE = "CA"; | |
String CITY = "San_Francisco"; | |
String KEY = "YOUR_API_KEY"; | |
JsonSlurper jsonSlurper = new JsonSlurper(); | |
def jsonData = "http://api.wunderground.com/api/${KEY}/conditions/q/${STATE}/${CITY}.json".toURL().text; | |
def j = jsonSlurper.parseText(jsonData); | |
println """ | |
Current Temperature is: $j.current_observation.temperature_string | |
"""; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment