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("终止任务")