判断是否被检测自动化增加文本条件, 登录, 获取账号信息, 修改账号信息, 检查账号cookies为无头模式运行. 获取任务更改为2个工作线程防止队列任务过多

This commit is contained in:
work
2025-07-08 16:55:49 +08:00
parent 0eed2ca1dc
commit 818c01b1af
2 changed files with 10 additions and 9 deletions

View File

@@ -835,7 +835,7 @@ def check_account_status(page, cookies):
raise AuthException('该账户登录状态失效', 'invalid')
# 判断是否被检测到自动化,这种情况只需要点击按钮就可以继续
if page.query_selector('//span[text()="We suspect automated behavior on your account"]') is not None:
if page.query_selector('//span[text()="We suspect automated behaviour on your account" or text()="We suspect automated behavior on your account"]') is not None:
page.click('//span[text()="Dismiss"]')
time.sleep(3)
retry_goto(page, 'https://www.facebook.com')
@@ -1055,7 +1055,7 @@ def playwright_get_user_profile(cookies, username=None):
with sync_playwright() as playwright:
update_windows_distinguish()
browser = playwright.chromium.launch(
headless=False, args=['--start-maximized'], executable_path=path
headless=True, args=['--start-maximized'], executable_path=path
)
context = browser.new_context(no_viewport=True)
context.add_cookies(parse_cookies(cookies))
@@ -1099,11 +1099,11 @@ def playwright_set_user_profile(cookies, username=None, first_name=None, last_na
return
path = os.path.join(BASE_PATH, 'chrome', '130-0008', 'chrome.exe')
with lock:
with login_semaphore:
with sync_playwright() as playwright:
update_windows_distinguish()
browser = playwright.chromium.launch(
headless=False, args=['--start-maximized'], executable_path=path
headless=True, args=['--start-maximized'], executable_path=path
)
context = browser.new_context(no_viewport=True)
context.add_cookies(parse_cookies(cookies))
@@ -1163,7 +1163,7 @@ def playwright_check_account_cookies(cookies):
with sync_playwright() as playwright:
update_windows_distinguish()
browser = playwright.chromium.launch(
headless=False, args=['--start-maximized'], executable_path=path
headless=True, args=['--start-maximized'], executable_path=path
)
context = browser.new_context(no_viewport=True)
context.add_cookies(parse_cookies(cookies))
@@ -1351,7 +1351,7 @@ def playwright_m_login(username, password, code_2fa=None):
with sync_playwright() as playwright:
update_windows_distinguish()
browser = playwright.chromium.launch(
headless=False, args=['--start-maximized'], executable_path=path
headless=True, args=['--start-maximized'], executable_path=path
)
# random_user_agent = UserAgent().getBrowser(["Chrome Mobile iOS"]).get("useragent")
random_user_agent = "Mozilla/5.0 (Linux; Android 12; Pixel 6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.41 Mobile Safari/537.36"