Created
May 29, 2018 10:45
-
-
Save PattyAppier/e364f071f354137cab557adee52f0880 to your computer and use it in GitHub Desktop.
PattysGooPy_2018_0529
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
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