해결된 질문
작성
·
73
0
알려주신대로,
def StockListing() :
import requests
import pandas as pd
import json
try :
from pandas import json_normalize
except importError:
from pandas.io.json import json_normalize
data = {'bld':'dbms/comm/finder/finder_stkisu', 'locale':'ko_KR',}
r = requests.post('http://data.krx.co.kr/comm/bldAttendant/getjsondata.cmd', data=data)
jo = json.loads(r.text)
df = json_normalize(jo,'block1')
df_info = df[['short_code', 'codeName']]
df_info.columns = ['Symbol','Name']
return df_info
df = StockListing()
JSONDecodeError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_3876\2969629370.py in <module>
19 df_info.columns = ['Symbol','Name']
20 return df_info
---> 21 df = StockListing()
~\AppData\Local\Temp\ipykernel_3876\2969629370.py in StockListing()
13
14 r = requests.post('http://data.krx.co.kr/comm/bldAttendant/getjsondata.cmd', data=data)
---> 15 jo = json.loads(r.text)
16 df = json_normalize(jo,'block1')
17 df_info = df[['short_code', 'codeName']]
~\anaconda3\lib\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\lib\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\lib\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 16 column 3 (char 36)
이런 오류가 나는데, 어떻게 해결해야 할까요?
답변