karl_TUM karl_TUM - 8 months ago 49
Python Question

python: Google Street View url request cannot load as json()

I want to use python to grab Google Street View image.
For example:


I run the following code:

import requests
result = requests.get(url)

But it comes out an error:

Traceback (most recent call last):

File "<ipython-input-69-180c2a4b335d>", line 1, in <module>

File "/home/kang/.local/lib/python3.4/site-packages/requests/models.py", line 826, in json
return complexjson.loads(self.text, **kwargs)

File "/home/kang/.local/lib/python3.4/site-packages/simplejson/__init__.py", line 516, in loads
return _default_decoder.decode(s)

File "/home/kang/.local/lib/python3.4/site-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)

File "/home/kang/.local/lib/python3.4/site-packages/simplejson/decoder.py", line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())

JSONDecodeError: Expecting value

The response of this url is:

enter image description here

How to fix that?
Thank you very much.

Answer Source

There is no JSON in the response that is coming back to you, which is why it is giving the error.