-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmuju_gondora_reservation_5s_check.py
More file actions
60 lines (47 loc) · 1.84 KB
/
muju_gondora_reservation_5s_check.py
File metadata and controls
60 lines (47 loc) · 1.84 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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()