Skip to content

Instantly share code, notes, and snippets.

@matthallamew
Last active September 16, 2015 15:37
Show Gist options
  • Save matthallamew/25bbd0bda159ed84b59c to your computer and use it in GitHub Desktop.
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.
#!/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