From 7c01de0aaefc7476c0a51049878a8bf9108216a8 Mon Sep 17 00:00:00 2001 From: work Date: Tue, 27 May 2025 09:19:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dm=E7=99=BB=E5=BD=95=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E4=BC=9A=E8=B7=B3=E5=88=B0=E9=A6=96=E9=A1=B5=E5=92=8C?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E8=B6=85=E6=97=B6=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spider/task.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spider/task.py b/spider/task.py index c3d9995..0da4dda 100644 --- a/spider/task.py +++ b/spider/task.py @@ -1185,7 +1185,7 @@ def retry_goto(page: "Page", url: str, max_retries: int = 3, retry_delay: int = # Make the synchronous goto call within the try block # Use wait_until='load' as in your traceback, or adjust if needed - page.goto(url, timeout=30000) # Use the synchronous call + page.goto(url, timeout=30000, wait_until="domcontentloaded") # Use the synchronous call print(f"Successfully navigated to {url} on attempt {attempt + 1}") break # Navigation was successful, exit the retry loop @@ -1350,14 +1350,13 @@ def playwright_m_login(username, password, code_2fa=None): }, ]) page = context.new_page() - url = 'https://m.facebook.com' + url = 'https://m.facebook.com/login' retry_goto(page, url) page.locator('//input[@id="m_login_email"]').type(username, delay=30) time.sleep(random.randint(1, 3)) page.locator('//input[@id="m_login_password"]').type(password, delay=30) time.sleep(random.randint(1, 3)) page.click('//div[@aria-label="Log in"]') - page.wait_for_load_state() time.sleep(random.randint(3, 5)) success_login_selector = '//span[text()="Check your notifications on another device"]' @@ -1369,9 +1368,11 @@ def playwright_m_login(username, password, code_2fa=None): failed_login = page.query_selector(failed_login_selector) if failed_login: # 登录失败, 返回失败信息 + logger.info(f"用户名:{username} 密码错误 {failed_login.text_content()}") raise OperationFailed(failed_login.text_content()) logger.info(f"用户名:{username} 账号密码正确") + time.sleep(3) raise OperationFailed("终止任务")