Spaces:
Running
Running
nacho commited on
Commit ·
4b9c49a
1
Parent(s): caaf954
fix: 登录前自动点击「密码登录」选项卡,解决页面默认显示手机验证码登录导致找不到邮箱输入框的问题
Browse files- deepseek_browser.py +17 -1
deepseek_browser.py
CHANGED
|
@@ -113,9 +113,25 @@ class DeepSeekBrowser:
|
|
| 113 |
async def _auto_login(self):
|
| 114 |
logger.info("Logging in as %s...", self.email)
|
| 115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
try:
|
| 117 |
email_input = self.page.locator('input[placeholder*="邮箱"], input[placeholder*="手机"], input[placeholder*="Email"], input[placeholder*="email"], input[type="text"]').first
|
| 118 |
-
await email_input.wait_for(state="visible", timeout=
|
| 119 |
await email_input.fill(self.email)
|
| 120 |
await asyncio.sleep(0.5)
|
| 121 |
except Exception as e:
|
|
|
|
| 113 |
async def _auto_login(self):
|
| 114 |
logger.info("Logging in as %s...", self.email)
|
| 115 |
|
| 116 |
+
# 1. 先等待页面加载完成(任意输入框出现),防止因为 Cloudflare 还在转圈导致直接尝试点击失败
|
| 117 |
+
try:
|
| 118 |
+
any_input = self.page.locator('input').first
|
| 119 |
+
await any_input.wait_for(state="visible", timeout=30000)
|
| 120 |
+
except Exception:
|
| 121 |
+
pass
|
| 122 |
+
|
| 123 |
+
# 2. 尝试切换到“密码登录”模式(如果页面默认是手机验证码登录)
|
| 124 |
+
try:
|
| 125 |
+
pwd_tab = self.page.locator('text="密码登录"').first
|
| 126 |
+
if await pwd_tab.is_visible():
|
| 127 |
+
await pwd_tab.click()
|
| 128 |
+
await asyncio.sleep(0.5)
|
| 129 |
+
except Exception as e:
|
| 130 |
+
logger.debug("No password login tab found or error: %s", e)
|
| 131 |
+
|
| 132 |
try:
|
| 133 |
email_input = self.page.locator('input[placeholder*="邮箱"], input[placeholder*="手机"], input[placeholder*="Email"], input[placeholder*="email"], input[type="text"]').first
|
| 134 |
+
await email_input.wait_for(state="visible", timeout=10000)
|
| 135 |
await email_input.fill(self.email)
|
| 136 |
await asyncio.sleep(0.5)
|
| 137 |
except Exception as e:
|