-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.py
36 lines (28 loc) · 1.05 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import win32com.client
# 연결 여부 체크
objCpCybos = win32com.client.Dispatch("CpUtil.CpCybos")
bConnect = objCpCybos.IsConnect
if (bConnect == 0):
print("PLUS가 정상적으로 연결되지 않음. ")
exit()
# 현재가 객체 구하기
objStockMst = win32com.client.Dispatch("DsCbo1.StockMst")
objStockMst.SetInputValue(0, 'A005930') #종목 코드 - 삼성전자
objStockMst.BlockRequest()
# 현재가 통신 및 통신 에러 처리
rqStatus = objStockMst.GetDibStatus()
rqRet = objStockMst.GetDibMsg1()
print("통신상태", rqStatus, rqRet)
if rqStatus != 0:
exit()
# 현재가 정보 조회
offer = objStockMst.GetHeaderValue(16) #매도호가
import requests
def post_message(token, channel, text):
response = requests.post("https://slack.com/api/chat.postMessage",
headers={"Authorization": "Bearer "+token},
data={"channel": channel,"text": text}
)
print(response)
myToken = "xoxb-3504057626451-3504117030802-PGaLLFMfTCVHW2ErLT3DJFcU"
post_message(myToken,"#stock","삼성전자 현재가:" + str(offer))