Open KevinFire2030 opened 1 year ago
import pandas as pd
def read_krx_code(self):
"""KRX로부터 상장기업 목록 파일을 읽어와서 데이터프레임으로 반환"""
url = 'http://kind.krx.co.kr/corpgeneral/corpList.do?method='\
'download&searchType=13'
krx = pd.read_html(url, header=0)[0]
krx = krx[['종목코드', '회사명']]
krx = krx.rename(columns={'종목코드': 'code', '회사명': 'company'})
krx.code = krx.code.map('{:06d}'.format)
return krx
1934 / 2626
급등주: 372290
1935 / 2626
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.3.2\plugins\python-ce\helpers\pydev\pydevd.py", line 1496, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.3.2\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "D:\Fire2025\23W23\book\ch19\pymon.py", line 114, in <module>
pymon.run()
File "D:\Fire2025\23W23\book\ch19\pymon.py", line 105, in run
if self.check_speedy_rising_volume(code):
File "D:\Fire2025\23W23\book\ch19\pymon.py", line 68, in check_speedy_rising_volume
df = self.get_ohlcv(code, today)
File "D:\Fire2025\23W23\book\ch19\pymon.py", line 53, in get_ohlcv
df = web.DataReader(code, 'naver', end=end)
File "D:\Anaconda3\envs\py39_32\lib\site-packages\pandas\util\_decorators.py", line 211, in wrapper
return func(*args, **kwargs)
File "D:\Anaconda3\envs\py39_32\lib\site-packages\pandas_datareader\data.py", line 662, in DataReader
return NaverDailyReader(
File "D:\Anaconda3\envs\py39_32\lib\site-packages\pandas_datareader\base.py", line 253, in read
df = self._read_one_data(self.url, params=self._get_params(self.symbols))
File "D:\Anaconda3\envs\py39_32\lib\site-packages\pandas_datareader\naver.py", line 81, in _read_one_data
prices = DataFrame(
File "D:\Anaconda3\envs\py39_32\lib\site-packages\pandas\core\frame.py", line 738, in __init__
data = list(data)
File "D:\Anaconda3\envs\py39_32\lib\site-packages\pandas_datareader\naver.py", line 104, in _parse_xml_response
root = ElementTree.fromstring(xml_content)
File "D:\Anaconda3\envs\py39_32\lib\xml\etree\ElementTree.py", line 1349, in XML
parser.feed(text)
xml.etree.ElementTree.ParseError: XML or text declaration not at start of entity: line 3, column 0
python-BaseException