import win32com.client
import pythoncom
class XASessionEventHandler:
login_state = 0
def OnLogin(self, code, msg):
if code == "0000":
print("로그인 성공")
XASessionEventHandler.login_state = 1
else:
print("로그인 실패")
class XAQueryEventHandlerT1102:
query_state = 0
def OnReceiveData(self, code):
XAQueryEventHandlerT1102.query_state = 1
# ----------------------------------------------------------------------------
# login
# ----------------------------------------------------------------------------
id = "XXX"
passwd = "YYY"
cert_passwd = "ZZZ"
instXASession = win32com.client.DispatchWithEvents("XA_Session.XASession", XASessionEventHandler)
instXASession.ConnectServer("hts.ebestsec.co.kr", 20001)
instXASession.Login(id, passwd, cert_passwd, 0, 0)
while XASessionEventHandler.login_state == 0:
pythoncom.PumpWaitingMessages()
# ----------------------------------------------------------------------------
# t1102
# ----------------------------------------------------------------------------
instXAQueryT1102 = win32com.client.DispatchWithEvents("XA_DataSet.XAQuery", XAQueryEventHandlerT1102)
instXAQueryT1102.ResFileName = "C:\\eBEST\\xingAPI\\Res\\t1102.res"
instXAQueryT1102.SetFieldData("t1102InBlock", "shcode", 0, "078020")
instXAQueryT1102.Request(0)
while XAQueryEventHandlerT1102.query_state == 0:
pythoncom.PumpWaitingMessages()
name = instXAQueryT1102.GetFieldData("t1102OutBlock", "hname", 0)
price = instXAQueryT1102.GetFieldData("t1102OutBlock", "price", 0)
print(name)
print(price)
'Language > python' 카테고리의 다른 글
[ Python library ] 주식 현재가 추출 함수(naver증권 webcrolling) (0) | 2021.06.03 |
---|---|
[ Python library ] 네이버 encparam 추출 함수 (0) | 2021.06.03 |
Dash board (0) | 2021.05.18 |
로드러너 스크립트에서 mip호출 url건수 세어 엑셀 만들기 (0) | 2021.05.17 |
http 호출 url들을 추출하여 엑셀생성 (0) | 2021.05.17 |