登录提示自动化程序检测直接无视

This commit is contained in:
Your Name
2025-08-26 22:38:21 +08:00
parent 057204caee
commit 2b476b6e9b

View File

@@ -824,7 +824,7 @@ def playwright_login(username, password, code_2fa=None):
def get_proxy_from_api(): def get_proxy_from_api():
"""从代理API获取代理地址""" """从代理API获取代理地址"""
if os.getenv("dev") is not None: if os.getenv("dev") is not None:
return f"http://192.168.1.69:1080" return f"http://127.0.0.1:1080"
try: try:
# 假设你的代理API地址 # 假设你的代理API地址
proxy_api_url = const.PROXY_HOST proxy_api_url = const.PROXY_HOST
@@ -853,7 +853,7 @@ def playwright_m_login(username, password, code_2fa=None):
with sync_playwright() as playwright: with sync_playwright() as playwright:
update_windows_distinguish() update_windows_distinguish()
proxy_url = get_proxy_from_api() proxy_url = get_proxy_from_api()
logger.info(f"使用proxi={proxy_url}") logger.info(f"使用proxy={proxy_url}")
browser = playwright.chromium.launch( browser = playwright.chromium.launch(
headless=const.HEADLESS, args=['--start-maximized'], executable_path=path, proxy={ headless=const.HEADLESS, args=['--start-maximized'], executable_path=path, proxy={
@@ -936,9 +936,12 @@ def playwright_m_login(username, password, code_2fa=None):
# 点击继续 # 点击继续
page.query_selector('div[role="button"][aria-label="Continue"]').click() page.query_selector('div[role="button"][aria-label="Continue"]').click()
# 等待登录成功 # 等待登录成功, 账号被检测自动化程序会卡在这里. 直接忽略报错
page.wait_for_selector('img[data-bloks-name="bk.components.Image"][src*=".fbcdn.net/v/t"]', timeout=60000) try:
page.wait_for_selector('img[data-bloks-name="bk.components.Image"][src*=".fbcdn.net/v/t"]',
timeout=60000)
except Exception as e:
pass
# 成功 # 成功
logger.info(f"用户名:{username} 账号密码正确") logger.info(f"用户名:{username} 账号密码正确")