diff --git a/build.spec b/build.spec index c41e5ad..e797145 100644 --- a/build.spec +++ b/build.spec @@ -18,11 +18,15 @@ a = Analysis( ('uBlock0.chromium', 'uBlock0.chromium'), ('cursor_auth.py', '.'), ('reset_machine_manual.py', '.'), - ('cursor_register.py', '.') + ('cursor_register.py', '.'), + ('browser.py', '.'), + ('control.py', '.') ], hiddenimports=[ 'cursor_auth', - 'reset_machine_manual' + 'reset_machine_manual', + 'browser', + 'control' ], hookspath=[], hooksconfig={}, diff --git a/control.py b/control.py index c005ac1..889335b 100644 --- a/control.py +++ b/control.py @@ -215,28 +215,29 @@ class BrowserControl: def get_verification_code(self): """从邮件中获取验证码""" try: - # 使用新的 XPath 定位验证码 - code_div = self.browser.ele('xpath://div[contains(@style, "font-family:-apple-system") and contains(@style, "font-size:28px") and contains(@style, "letter-spacing:2px") and contains(@style, "color:#202020")]') + # 尝试所有可能的样式组合 + selectors = [ + # 新样式 + 'xpath://div[contains(@style, "font-family:-apple-system") and contains(@style, "font-size:28px") and contains(@style, "letter-spacing:2px") and contains(@style, "color:#202020")]', + # 带行高的样式 + 'xpath://div[contains(@style, "font-size:28px") and contains(@style, "letter-spacing:2px") and contains(@style, "line-height:30px")]', + # rgba 颜色样式 + 'xpath://div[contains(@style, "font-size: 28px") and contains(@style, "letter-spacing: 2px") and contains(@style, "color: rgba(32, 32, 32, 1)")]', + # 宽松样式 + 'xpath://div[contains(@style, "font-size:28px") and contains(@style, "letter-spacing:2px")]' + ] - # 如果找不到,尝试备用选择器 - if not code_div: - code_div = self.browser.ele('xpath://div[contains(@style, "font-size:28px") and contains(@style, "letter-spacing:2px") and contains(@style, "line-height:30px")]') - - # 如果还找不到,尝试更宽松的选择器 - if not code_div: - code_div = self.browser.ele('xpath://div[contains(@style, "font-size:28px") and contains(@style, "letter-spacing:2px")]') - - if code_div: - verification_code = code_div.text.strip() - if verification_code.isdigit() and len(verification_code) == 6: - print(f"{Fore.GREEN}Found Verification Code | 找到验证码: {verification_code}{Style.RESET_ALL}") - return verification_code - else: - print(f"{Fore.RED}Verification Code Format Error | 验证码格式不正确: {verification_code}{Style.RESET_ALL}") - return None - else: - print(f"{Fore.YELLOW}No Verification Code Found | 未找到验证码{Style.RESET_ALL}") - return None + # 依次尝试每个选择器 + for selector in selectors: + code_div = self.browser.ele(selector) + if code_div: + verification_code = code_div.text.strip() + if verification_code.isdigit() and len(verification_code) == 6: + print(f"{Fore.GREEN}Found Verification Code | 找到验证码: {verification_code}{Style.RESET_ALL}") + return verification_code + + print(f"{Fore.YELLOW}No Valid Verification Code Found | 未找到有效验证码{Style.RESET_ALL}") + return None except Exception as e: print(f"{Fore.RED}Get Verification Code Error | 获取验证码时发生错误: {str(e)}{Style.RESET_ALL}") diff --git a/images/fix_2025-01-14_21-30-43.png b/images/fix_2025-01-14_21-30-43.png new file mode 100644 index 0000000..9aa24a8 Binary files /dev/null and b/images/fix_2025-01-14_21-30-43.png differ