Reputation: 21
`headers={'user-agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36', ... 'accept-language':'en-US,en;q=0.9,bn;q=0.8','accept-encoding':'gzip, deflate, br'}
url='https://www.nseindia.com/api/equity-stock?index=fu_niftybank' r = requests.get(url,headers=headers).json() Traceback (most recent call last): File "", line 1, in File "C:\ProgramData\Anaconda3\lib\site-packages\requests\models.py", line 900, in json return complexjson.loads(self.text, **kwargs) File "C:\ProgramData\Anaconda3\lib\site-packages\simplejson_init_.py", line 525, in loads return _default_decoder.decode(s) File "C:\ProgramData\Anaconda3\lib\site-packages\simplejson\decoder.py", line 370, in decode obj, end = self.raw_decode(s) File "C:\ProgramData\Anaconda3\lib\site-packages\simplejson\decoder.py", line 400, in raw_decode return self.scan_once(s, idx=_w(s, idx).end()) File "C:\ProgramData\Anaconda3\lib\site-packages\simplejson\scanner.py", line 79, in scan_once return _scan_once(string, idx) File "C:\ProgramData\Anaconda3\lib\site-packages\simplejson\scanner.py", line 70, in _scan_once raise JSONDecodeError(errmsg, string, idx) simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)`
Upvotes: 0
Views: 34
Reputation: 1
This error simplejson.errors.JSONDecodeError
means that requests was unable to decode json for the site. I took a look at the link and it's not json it just returns html - https://www.nseindia.com/api/equity-stock?index=fu_niftybank. Must be an issue with the api, not your code.
Upvotes: 0