Skip to content

Instantly share code, notes, and snippets.

@prokizzle
Created May 26, 2014 16:34
Show Gist options
  • Save prokizzle/6f669bfd65de13a9fcfc to your computer and use it in GitHub Desktop.
Save prokizzle/6f669bfd65de13a9fcfc to your computer and use it in GitHub Desktop.
Pythonista - Driving Duration Calculator
import urllib2
import urllib
import json
import webbrowser
import sys
origin = "78704"
destination = urllib.quote(sys.argv[1],'')
response = urllib2.urlopen("http://maps.googleapis.com/maps/api/distancematrix/json?origins={0}&destinations={1}&mode=driving&sensor=false".format(origin, destination))
r= json.loads(response.read())
duration = str(r["rows"][0]["elements"][0]["duration"]["text"])
message = str(duration + " to " + destination)
webbrowser.open("http://dl.dropboxusercontent.com/u/1084227/endgame/index.html?h1=" + message + "&return=launchpro")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment