Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 사물인터넷
- 코딩
- Project
- 코딩독학
- java정리
- 풀스택프레임워크
- frontend
- SNS
- java
- 프로그래밍
- 개인프로젝트
- 개발자
- 백준
- 코딩테스트
- C++
- 자바정리
- 코스닥
- 개발
- 프로그래머스
- 코테
- 이웃한 칸
- backend
- Python
- Reflex
- 모의 주식
- 프로그램
- 빅데이터
- 주가예측
- 자바
- 자바독학
Archives
- Today
- Total
Creative Code
stockprice.py(주식가격 1분마다 카카오톡으로 받아오기) 본문
import json
import requests
import time
from bs4 import BeautifulSoup
def sendToMeMessage(text):
header = {"Authorization":"Bearer "+ KAKAO_TOKEN}
url = "https://kapi.kakao.com/v2/api/talk/memo/default/send"
post = {
"object_type":"text",
"text":text,
"link":{
"web_url":"https://developers.kakao.com",
"mobile_web_url":"https://developers.kakao.com"
},
"button_title":"immediately confirm"
}
data = {"template_object":json.dumps(post)}
return requests.post(url,headers=header,data=data)
KAKAO_TOKEN ="********************************************" // 자체모자이크처리
def get_price(com_code):
url = "https://finance.naver.com/item/main.nhn?code=" + com_code
result = requests.get(url, headers={'User-agent':'Mozilla/5.0'})
bs_obj = BeautifulSoup(result.content,"html.parser")
no_today = bs_obj.find("p",{"class":"no_today"})
blind_now=no_today.find("span",{"class":"blind"})
return blind_now.text
try:
while True:
text = "sinsung's stock price : " +get_price("065350")
print(sendToMeMessage(text).text)
time.sleep(60.0)
except KeyboardInterrupt:
pass
결과 화면
'Raspberry PI(Python)' 카테고리의 다른 글
piano.py(도,레,미,파,솔 소리내기) (0) | 2023.09.22 |
---|---|
led.py (led 1초간격으로 키고 끄기) (0) | 2023.09.21 |