Con el siguiente script, intento conseguir datos en el formato JSON.
# source = https://freshprinceofstandarderror.com/finance/fear-and-greed-index-data-in-python/
# getting data in JSON format
import requests, json
import pandas as pd
BASE_URL = "https://production.dataviz.cnn.io/index/fearandgreed/graphdata"
START_DATE = '2021-01-01'
r = requests.get("{}/{}".format(BASE_URL, START_DATE))
data = r.json()
Me devuelve el error
---------------------------------------------------------------------------
JSONDecodeError Traceback (most recent call last)
/tmp/ipykernel_4281/2898561448.py in <module>
9
10 r = requests.get("{}/{}".format(BASE_URL, START_DATE))
---> 11 data = r.json()
~/anaconda3/envs/yfinance/lib/python3.9/site-packages/requests/models.py in json(self, **kwargs)
899 if encoding is not None:
900 try:
--> 901 return complexjson.loads(
902 self.content.decode(encoding), **kwargs
903 )
~/anaconda3/envs/yfinance/lib/python3.9/json/__init__.py in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
344 parse_int is None and parse_float is None and
345 parse_constant is None and object_pairs_hook is None and not kw):
--> 346 return _default_decoder.decode(s)
347 if cls is None:
348 cls = JSONDecoder
~/anaconda3/envs/yfinance/lib/python3.9/json/decoder.py in decode(self, s, _w)
335
336 """
--> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
338 end = _w(s, end).end()
339 if end != len(s):
~/anaconda3/envs/yfinance/lib/python3.9/json/decoder.py in raw_decode(self, s, idx)
353 obj, end = self.scan_once(s, idx)
354 except StopIteration as err:
--> 355 raise JSONDecodeError("Expecting value", s, err.value) from None
356 return obj, end
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
¿Cómo puedo fijar este error?. Agradeceré ayuda.