Im trying to retrieve coordinates from an API but one of the json objects contains danish letters, and I keep getting an error. This is what I have:
# -*- coding: utf-8 -*-
import urllib2
import json
import codecs
url='http://geo.oiorest.dk/adresser.json?postnr=1577&vejnavn=bernstorffsgade&husnr=16'
addressline = "%s, %s"
try:
data = urllib2.urlopen(url).read().decode('utf-8')
adresser = json.loads(data, encoding='utf-8')
for adresse in adresser:
print addressline % \
(adresse['etrs89koordinat']['øst'],
adresse['etrs89koordinat']['nord'])
except urllib2.HTTPError, e:
print "HTTP error: %d" % e.code
except urllib2.URLError, e:
print "Network error: %s" % e.reason.args[1]
The Error I get:
KeyError: '\xc3\xb8st'