기타
도메인 만료 전 팀즈 채널 알림
앗사비
2021. 5. 10. 11:53
728x90
import whois # pip install python-whois
from datetime import datetime, timedelta
import time
import pymsteams
list = [
'www.naver.com', 'www.daum.net'
]
for hostname in list:
domain = whois.whois(hostname)
t = time.time()
today = time.strftime("%Y%m%d", time.gmtime(t))
date_now = datetime.strptime(today, "%Y%m%d").date()
date_exp = datetime.strptime(
str(domain.expiration_date[0]), "%Y-%m-%d %H:%M:%S").date()
diff = (date_exp - date_now).days
if diff < 30:
print(hostname, diff, date_exp)
else:
print(hostname, diff, date_exp)
noti = hostname + " 도메인 만료 " + \
str(diff) + "일 남았습니다" + " (" + str(date_exp) + ")"
myTeamsMessage = pymsteams.connectorcard("https://") #웹훅 주소 입력 (커넥터 구성하기)
myTeamsMessage.text(noti)
myTeamsMessage.send()
time.sleep(5)
728x90