Skip to content

Instantly share code, notes, and snippets.

@jjgod
Created September 9, 2014 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjgod/0e32f84ccbcae560928e to your computer and use it in GitHub Desktop.
Save jjgod/0e32f84ccbcae560928e to your computer and use it in GitHub Desktop.
from urllib2 import Request, urlopen, URLError
import json
import sys
import utm
utm_data = utm.from_latlon(59.948845,10.772473)
data = "coordinates=(x={0},y={1})&proposals={2}&maxdistance={3}".format(int(utm_data[0]), int(utm_data[1]), 10, 1400)
request = Request('http://reisapi.ruter.no/Place/GetClosestStops?{0}'.format(data))
try:
response = urlopen(request)
output = response.read()
stops = json.loads(output)
print json.dumps(stops, sort_keys=True, indent=4, separators=(',', ': '))
except URLError, e:
print 'Error', e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment