Created
September 9, 2014 10:56
-
-
Save jjgod/0e32f84ccbcae560928e to your computer and use it in GitHub Desktop.
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
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