From 943f57aaf691ba0a5c720dff67ca40b29d411fce Mon Sep 17 00:00:00 2001 From: Jaesang Jo Date: Wed, 15 Jan 2025 13:34:51 +0900 Subject: [PATCH] =?UTF-8?q?=EB=AC=B4=EC=A3=BC=EB=A6=AC=EC=A1=B0=ED=8A=B8?= =?UTF-8?q?=20=EA=B3=A4=EB=8F=84=EB=9D=BC=20=EC=9E=94=EC=97=AC=EC=84=9D=20?= =?UTF-8?q?=EC=8B=A4=EC=8B=9C=EA=B0=84=20=EC=B2=B4=ED=81=AC=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 파이썬을 구동할 수 있어야 하며, 문자 발송은제이문자 앱을 통해서 할 수 있습니다. 2025/01/15 --- muju_gondora_reservation_5s_check.py | 60 ++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 muju_gondora_reservation_5s_check.py diff --git a/muju_gondora_reservation_5s_check.py b/muju_gondora_reservation_5s_check.py new file mode 100644 index 0000000..be5b128 --- /dev/null +++ b/muju_gondora_reservation_5s_check.py @@ -0,0 +1,60 @@ +import requests +from bs4 import BeautifulSoup +import smtplib +from email.mime.text import MIMEText +from email.mime.multipart import MIMEMultipart +from jmunja import smssend +import time # 추가된 모듈 + + +# 예약 사이트 URL +URL = "https://www.mdysresort.com/gondora/res_gon1.asp?" + + +# 예약 상태 확인 함수 +def check_availability(): + try: + response = requests.get(URL, timeout=5) + response.raise_for_status() + + soup = BeautifulSoup(response.text, "html.parser") + reservation_elements = soup.select("#res_gon1 > div > div.cal_con > div.calendar_box > div:nth-child(4) > ul.sat > li.res") + + for element in reservation_elements: + if "매진" not in element.text: + return True # 예약 가능 상태 발견 + return False # 모든 항목이 매진 상태 + except requests.exceptions.Timeout: + print("Request timed out. Please try again.") + except requests.exceptions.RequestException as e: + print(f"An error occurred: {e}") + + +# SMS 보내기 함수 (제이문자) +def send_sms_notification(): + uid = "" + upw = "" + subject = "곤도라예약" + content = "곤도라 예약이 가능합니다! 지금 바로 사이트를 방문하세요: " + URL, + + jphone = smssend.JmunjaPhone(uid, upw) + result = jphone.send(subject, content, "01012345678") + + if result: + print("SMS 발송 완료") + + +# 메인 함수 +def main(): + while True: + if check_availability(): + print("예약 가능 상태 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") + send_sms_notification() + time.sleep(30) + else: + print("모든 예약이 매진 상태입니다.") + pass + time.sleep(5) + +if __name__ == "__main__": + main()