|
@@ -302,19 +302,19 @@ class ItaPlugin(IVSPlg):
|
|
|
elif self.page.ele('@name=callback_1', timeout=1):
|
|
elif self.page.ele('@name=callback_1', timeout=1):
|
|
|
self._log("[State] PingID Login Form detected. Submitting credentials...")
|
|
self._log("[State] PingID Login Form detected. Submitting credentials...")
|
|
|
|
|
|
|
|
- print("正在输入账号...")
|
|
|
|
|
|
|
+ self._log("Entering username...")
|
|
|
user_input = self.page.ele('@name=callback_1')
|
|
user_input = self.page.ele('@name=callback_1')
|
|
|
self.mouse.human_click_ele(user_input)
|
|
self.mouse.human_click_ele(user_input)
|
|
|
user_input.input(username, clear=True)
|
|
user_input.input(username, clear=True)
|
|
|
time.sleep(1) # 模拟人手停顿
|
|
time.sleep(1) # 模拟人手停顿
|
|
|
|
|
|
|
|
- print("正在输入密码...")
|
|
|
|
|
|
|
+ self._log("Entering password...")
|
|
|
pwd_input = self.page.ele('@type=password')
|
|
pwd_input = self.page.ele('@type=password')
|
|
|
self.mouse.human_click_ele(pwd_input)
|
|
self.mouse.human_click_ele(pwd_input)
|
|
|
pwd_input.input(password, clear=True)
|
|
pwd_input.input(password, clear=True)
|
|
|
time.sleep(1)
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
- print("正在点击登录按钮...")
|
|
|
|
|
|
|
+ self._log("Clicking submit login button...")
|
|
|
submit_btn = self.page.ele('tag:button@type=submit')
|
|
submit_btn = self.page.ele('tag:button@type=submit')
|
|
|
self.mouse.human_click_ele(submit_btn)
|
|
self.mouse.human_click_ele(submit_btn)
|
|
|
|
|
|
|
@@ -368,16 +368,16 @@ class ItaPlugin(IVSPlg):
|
|
|
# ==========================================
|
|
# ==========================================
|
|
|
# 步骤 1:在服务列表中寻找并点击目标服务的 Book
|
|
# 步骤 1:在服务列表中寻找并点击目标服务的 Book
|
|
|
# ==========================================
|
|
# ==========================================
|
|
|
- print("等待服务列表加载...")
|
|
|
|
|
|
|
+ self._log("Waiting for service list to load...")
|
|
|
self.page.wait.eles_loaded('@aria-controls=dataTableServices', timeout=10)
|
|
self.page.wait.eles_loaded('@aria-controls=dataTableServices', timeout=10)
|
|
|
|
|
|
|
|
- print(f"正在查找 [{TARGET_SERVICE}] 的 Book 按钮...")
|
|
|
|
|
|
|
+ self._log(f"Searching for [{TARGET_SERVICE}] Book button...")
|
|
|
# 使用 XPath:找包含 TARGET_SERVICE 文本的行(tr),再找该行里包含 Book 的超链接(a)
|
|
# 使用 XPath:找包含 TARGET_SERVICE 文本的行(tr),再找该行里包含 Book 的超链接(a)
|
|
|
target_book_btn_xpath = f'xpath://tr[contains(., "{TARGET_SERVICE}")]//a[contains(text(), "Book")]'
|
|
target_book_btn_xpath = f'xpath://tr[contains(., "{TARGET_SERVICE}")]//a[contains(text(), "Book")]'
|
|
|
book_btn = self.page.ele(target_book_btn_xpath)
|
|
book_btn = self.page.ele(target_book_btn_xpath)
|
|
|
|
|
|
|
|
if not book_btn:
|
|
if not book_btn:
|
|
|
- print(f"未找到 {TARGET_SERVICE} 的 Book 按钮,可能当前无号,程序退出。")
|
|
|
|
|
|
|
+ self._log(f"Target [{TARGET_SERVICE}] Book button not found, currently no slots available.")
|
|
|
# 这里可以根据你的逻辑 return 或者 raise Exception
|
|
# 这里可以根据你的逻辑 return 或者 raise Exception
|
|
|
else:
|
|
else:
|
|
|
self.mouse.human_click_ele(book_btn)
|
|
self.mouse.human_click_ele(book_btn)
|
|
@@ -388,21 +388,19 @@ class ItaPlugin(IVSPlg):
|
|
|
# ==========================================
|
|
# ==========================================
|
|
|
# 步骤 2:填写预约表单
|
|
# 步骤 2:填写预约表单
|
|
|
# ==========================================
|
|
# ==========================================
|
|
|
- print("等待预约表单加载...")
|
|
|
|
|
|
|
+ self._log("Waiting for booking form to load...")
|
|
|
self.page.wait.eles_loaded('#bookingForm', timeout=10)
|
|
self.page.wait.eles_loaded('#bookingForm', timeout=10)
|
|
|
|
|
|
|
|
- print("1. 选择预约类型...")
|
|
|
|
|
|
|
+ self._log("Selecting booking type & reason...")
|
|
|
typeofbooking_ddl = self.page.ele('#typeofbookingddl')
|
|
typeofbooking_ddl = self.page.ele('#typeofbookingddl')
|
|
|
# DrissionPage select 方法直接按文本选中,会自动触发网页的 JS 联动
|
|
# DrissionPage select 方法直接按文本选中,会自动触发网页的 JS 联动
|
|
|
typeofbooking_ddl.select('Individual booking')
|
|
typeofbooking_ddl.select('Individual booking')
|
|
|
time.sleep(1)
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
- print("2. 选择到访原因...")
|
|
|
|
|
reason_ddl = self.page.ele('#ddls_0')
|
|
reason_ddl = self.page.ele('#ddls_0')
|
|
|
reason_ddl.select(REASON_FOR_VISIT)
|
|
reason_ddl.select(REASON_FOR_VISIT)
|
|
|
time.sleep(1)
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
- print("3. 填写备注...")
|
|
|
|
|
notes_input = self.page.ele('#BookingNotes')
|
|
notes_input = self.page.ele('#BookingNotes')
|
|
|
notes_input.clear()
|
|
notes_input.clear()
|
|
|
notes_input.input('N/A') # 选填,填入 N/A 或者留空
|
|
notes_input.input('N/A') # 选填,填入 N/A 或者留空
|
|
@@ -411,16 +409,14 @@ class ItaPlugin(IVSPlg):
|
|
|
# ==========================================
|
|
# ==========================================
|
|
|
# 步骤 3:处理 OTP 验证码
|
|
# 步骤 3:处理 OTP 验证码
|
|
|
# ==========================================
|
|
# ==========================================
|
|
|
- print("4. 点击发送 OTP 验证码...")
|
|
|
|
|
|
|
+ self._log("Sending OTP code...")
|
|
|
otp_send_btn = self.page.ele('#otp-send')
|
|
otp_send_btn = self.page.ele('#otp-send')
|
|
|
self.mouse.human_click_ele(otp_send_btn)
|
|
self.mouse.human_click_ele(otp_send_btn)
|
|
|
|
|
|
|
|
# 这是一个 AJAX 请求,会转圈圈。我们需要等待成功提示出现
|
|
# 这是一个 AJAX 请求,会转圈圈。我们需要等待成功提示出现
|
|
|
- print("等待验证码发送成功的提示...")
|
|
|
|
|
self.page.wait.ele_displayed('#IdOtpSent', timeout=15) # 等待绿字 "New code sent!" 显示
|
|
self.page.wait.ele_displayed('#IdOtpSent', timeout=15) # 等待绿字 "New code sent!" 显示
|
|
|
- print("验证码已发送!")
|
|
|
|
|
|
|
+ self._log("OTP code sent successfully.")
|
|
|
|
|
|
|
|
- print("5. 填写默认验证码 123456 ...")
|
|
|
|
|
otp_input = self.page.ele('#otp-input')
|
|
otp_input = self.page.ele('#otp-input')
|
|
|
self.mouse.human_click_ele(otp_input)
|
|
self.mouse.human_click_ele(otp_input)
|
|
|
otp_input.input('123456')
|
|
otp_input.input('123456')
|
|
@@ -429,20 +425,19 @@ class ItaPlugin(IVSPlg):
|
|
|
# ==========================================
|
|
# ==========================================
|
|
|
# 步骤 4:勾选隐私政策并提交
|
|
# 步骤 4:勾选隐私政策并提交
|
|
|
# ==========================================
|
|
# ==========================================
|
|
|
- print("6. 勾选隐私政策...")
|
|
|
|
|
privacy_checkbox = self.page.ele('#PrivacyCheck')
|
|
privacy_checkbox = self.page.ele('#PrivacyCheck')
|
|
|
# 判断一下如果没勾上才去点,防止重复点击取消了
|
|
# 判断一下如果没勾上才去点,防止重复点击取消了
|
|
|
if not privacy_checkbox.states.is_checked:
|
|
if not privacy_checkbox.states.is_checked:
|
|
|
self.mouse.human_click_ele(privacy_checkbox)
|
|
self.mouse.human_click_ele(privacy_checkbox)
|
|
|
time.sleep(1)
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
- print("7. 点击 Forward 提交表单...")
|
|
|
|
|
|
|
+ self._log("Submitting forward form...")
|
|
|
forward_btn = self.page.ele('#btnAvanti')
|
|
forward_btn = self.page.ele('#btnAvanti')
|
|
|
self.mouse.human_click_ele(forward_btn)
|
|
self.mouse.human_click_ele(forward_btn)
|
|
|
|
|
|
|
|
# 提交后页面会跳转,等待加载开始
|
|
# 提交后页面会跳转,等待加载开始
|
|
|
self.page.wait.load_start()
|
|
self.page.wait.load_start()
|
|
|
- print("表单已提交!当前页面:", self.page.url)
|
|
|
|
|
|
|
+ self._log(f"Form submitted. Current page: {self.page.url}")
|
|
|
|
|
|
|
|
time.sleep(5)
|
|
time.sleep(5)
|
|
|
|
|
|