diff --git a/StockCrawler.py b/StockCrawler.py index 25a32c1..903f1da 100644 --- a/StockCrawler.py +++ b/StockCrawler.py @@ -7,6 +7,7 @@ from stock.crawler.FnGuideCrawler import FnGuideCrawler from stock.crawler.MetaCrawler import MetaCrawler from stock.crawler.StockCrawler import StockCrawler from stock.analysis.AnalyzerSqlite import AnalyzerSqlite +from stock.util.SlackBot import SlackBot today = datetime.now().strftime("%Y-%m-%d") @@ -21,6 +22,8 @@ stockFileName = os.path.join(RESOURCE_PATH, 'stock.db') week = datetime.today().weekday() +slackBot = SlackBot() + if week in (0, 1, 2, 3, 4): # 0:월, 1:화, 2:수, 3:목, 4:금, 5:토, 6:일 # 재무제표는 3개월마다 다운로드를 한다. @@ -81,6 +84,7 @@ if week in (0, 1, 2, 3, 4): # 0:월, 1:화, 2:수, 3:목, 4:금, 5:토, 6:일 analyzerSqlite.findCandidate(outPath) + slackBot.sendMsg("Done. Crawling...") print("time : %6.2f 초", (time.time() - start)) print ("done...") diff --git a/stock/util/SlackBot.py b/stock/util/SlackBot.py index c4a1d10..b0c54e3 100644 --- a/stock/util/SlackBot.py +++ b/stock/util/SlackBot.py @@ -32,6 +32,21 @@ class SlackBot: return + def sendMsg(self, msg): + try: + this_time = datetime.now() + text = "DATE TIME:" + this_time.strftime('%Y-%m-%d %H:%M:%S') + ", " + "msg:" + msg + result = self.client.chat_postMessage( + channel=self.CHANNEL_ID, + text=text + ) + print(text) + + except SlackApiError as e: + print(f"Error posting message: {e}") + + return + if __name__ == "__main__": this_time = datetime.now()