Skip to content

Instantly share code, notes, and snippets.

@ChewingPencils
Created November 9, 2012 02:10
Show Gist options
  • Save ChewingPencils/4043278 to your computer and use it in GitHub Desktop.
Save ChewingPencils/4043278 to your computer and use it in GitHub Desktop.
voodoo_log_header #pythonista
import urllib2
import json
import pprint
import datetime
pp = pprint.PrettyPrinter(indent=4)
# Get Date
today = datetime.date.today()
header = today.strftime('# Daily Log For %Y-%m-%d (%A) #\n\n')
f = urllib2.urlopen('http://api.wunderground.com/api/8d503b201bb05e43/forecast/q/Mo/Kansas_City.json')
#f = urllib2.urlopen('http://api.wunderground.com/api/8d503b201bb05e43/geolookup/conditions/q/MO/kansas_city.json')
json_string = f.read()
parsed_json = json.loads(json_string)
fhigh = parsed_json['forecast']['simpleforecast']['forecastday'][0]['high']['fahrenheit']
fLow = parsed_json['forecast']['simpleforecast']['forecastday'][0]['low']['fahrenheit']
fConditions = parsed_json['forecast']['simpleforecast']['forecastday'][0]['conditions']
wOut = header+ "## Today's Weather ##\n\n- High: " + fhigh + '\n- Low: ' + fLow + '\n- Conditions: ' + fConditions + "\n\n## Today's Goals ##\n\n<# #>\n\n## Log ##\n\n"
print wOut
#location = parsed_json['location']['city']
#temp_f = parsed_json['simpleforecast']['forecastday']['high']
#print "Current temperature in %s is: %s" % (location, temp_f)
#pp.pprint(parsed_json)
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment