Skip to content

Instantly share code, notes, and snippets.

@sergiolucero
Created November 21, 2017 20:57
Show Gist options
  • Save sergiolucero/76c72ba27d270c845f9cd16280e33b58 to your computer and use it in GitHub Desktop.
Save sergiolucero/76c72ba27d270c845f9cd16280e33b58 to your computer and use it in GitHub Desktop.
google path
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