Created
November 21, 2017 20:57
-
-
Save sergiolucero/76c72ba27d270c845f9cd16280e33b58 to your computer and use it in GitHub Desktop.
google path
This file contains hidden or 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 json | |
| import pandas as pd | |
| import urllib.request | |
| ori='75+9th+Ave+New+York,+NY' | |
| des='MetLife+Stadium+1+MetLife+Stadium+Dr+East+Rutherford,+NJ+07073' | |
| dep=int(datetime.datetime.now().timestamp()) | |
| URL='https://maps.googleapis.com/maps/api/directions/json?origin=%s&destination=%s&departure_time=%d' %(ori,des,dep) | |
| URL+='&traffic_model=best_guess&key=AIzaSyB_ZS04dfON0PZVBRwhKTkeChK3rlYUgSk' | |
| with urllib.request.urlopen(URL) as url: | |
| data = json.loads(url.read().decode()) | |
| route= pd.DataFrame(data['routes'][0]['legs']) | |
| steps=pd.DataFrame(route.steps[0]) | |
| steps.to_html('ruta.html') | |
| print(route.T) | |
| print(steps) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment