fear-and-greed
fear-and-greed copied to clipboard
Get the error: JSONDecodeError: Expecting value: line 1 column 1 (char 0)
I try to get data in the JSON format doing
`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()`
It returned
`---------------------------------------------------------------------------
JSONDecodeError Traceback (most recent call last)
/tmp/ipykernel_4281/2898561448.py in
~/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)`
I will appreciate help to fix this problem