I have been working with a couple of web APIs but this one has me perplexed. I can't work out what im going wrong.
this code works on one api, but not this one.
response = urllib.request.urlopen(self.query_base)
reader = codecs.getreader("utf-8")
obj = json.load(reader(response))
return obj
this gives me the following errror
UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f602' in position 4096: character maps to <undefined>
I have tried:
response = urllib.request.urlopen(self.query_base)
obj = json.load(response.decode("utf-8"))
return obj
which gives:
AttributeError: 'HTTPResponse' object has no attribute 'decode'
and,
response = urllib.request.urlopen(self.query_base).read()
obj = json.load(response)
return obj
which gives
AttributeError: 'bytes' object has no attribute 'read'
and,
response = urllib.request.urlopen(self.query_base)
obj = json.load(response)
which gives
TypeError: the JSON object must be str, not 'bytes'
along with maany other combinations of things I have found in other similar threads on here
I don't remember ever having this problem before, im sure ive missed something but I can't see what.