Skip to content

Instantly share code, notes, and snippets.

@PattyAppier
Created May 29, 2018 10:45
Show Gist options
  • Save PattyAppier/e364f071f354137cab557adee52f0880 to your computer and use it in GitHub Desktop.
Save PattyAppier/e364f071f354137cab557adee52f0880 to your computer and use it in GitHub Desktop.
PattysGooPy_2018_0529
import urllib.request
import json
import ssl
import googleapiclient
endpoint = 'https://maps.googleapis.com/maps/api/distancematrix/json?'
ssl._create_default_https_context = ssl._create_unverified_context
api_key = 'AIzaSyC14nJwhxNKsRtDWZNZzM_vCu0D4imEwBs'
origin = input('where are you?: ').replace('','+')
destination = input('where do you want to go?: ').replace('','+')
mode = input('what kind of transportation tool you are using?:')
nav_request = 'origins={}&destinations={}&key={}'.format(origin, destination, api_key)
request = endpoint + nav_request
response = urllib.request.urlopen(request).read() # url String
distances = json.loads(response) #
print(distances)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment