修复登录标题可能有的其他内容, 修复登录继续按钮可能获取到多个
This commit is contained in:
@@ -1133,6 +1133,15 @@ def playwright_check_account_cookies(cookies):
|
|||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
||||||
|
def get_login_continue_btn(page):
|
||||||
|
bs = page.query_selector_all('//span[text()="Continue"]')
|
||||||
|
for b in bs:
|
||||||
|
if b.is_visible() and b.is_enabled():
|
||||||
|
return b
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def playwright_login(username, password, code_2fa=None):
|
def playwright_login(username, password, code_2fa=None):
|
||||||
path = os.path.join(BASE_PATH, 'chrome', '130-0008', 'chrome.exe')
|
path = os.path.join(BASE_PATH, 'chrome', '130-0008', 'chrome.exe')
|
||||||
with lock:
|
with lock:
|
||||||
@@ -1194,7 +1203,12 @@ def playwright_login(username, password, code_2fa=None):
|
|||||||
if h2 is None:
|
if h2 is None:
|
||||||
raise OperationFailed('页面有误')
|
raise OperationFailed('页面有误')
|
||||||
else:
|
else:
|
||||||
if h2.text_content() != "Check your notifications on another device":
|
text_contexts = [
|
||||||
|
"Go to your authentication app",
|
||||||
|
"Check your notifications on another device"
|
||||||
|
]
|
||||||
|
|
||||||
|
if not h2.text_content() in text_contexts:
|
||||||
raise OperationFailed("操作失败")
|
raise OperationFailed("操作失败")
|
||||||
auth_span = page.query_selector('//span[text()="Try Another Way" or text()="Try another way"]')
|
auth_span = page.query_selector('//span[text()="Try Another Way" or text()="Try another way"]')
|
||||||
if auth_span:
|
if auth_span:
|
||||||
@@ -1202,8 +1216,14 @@ def playwright_login(username, password, code_2fa=None):
|
|||||||
raise OperationFailed('缺少2FA密钥')
|
raise OperationFailed('缺少2FA密钥')
|
||||||
auth_code = pyotp.TOTP(code_2fa).now()
|
auth_code = pyotp.TOTP(code_2fa).now()
|
||||||
auth_span.click()
|
auth_span.click()
|
||||||
|
time.sleep(1)
|
||||||
page.click('//div[text()="Authentication app"]')
|
page.click('//div[text()="Authentication app"]')
|
||||||
page.click('//span[text()="Continue"]')
|
time.sleep(1)
|
||||||
|
# 可能会有多个Continue
|
||||||
|
btn = get_login_continue_btn(page)
|
||||||
|
if btn is None:
|
||||||
|
raise OperationFailed("操作失败")
|
||||||
|
btn.click()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
page.locator('//label[text()="Code"]/preceding-sibling::input').fill(auth_code)
|
page.locator('//label[text()="Code"]/preceding-sibling::input').fill(auth_code)
|
||||||
page.click('//span[text()="Continue"]')
|
page.click('//span[text()="Continue"]')
|
||||||
@@ -1258,8 +1278,8 @@ if __name__ == '__main__':
|
|||||||
# # lastname='Keals',
|
# # lastname='Keals',
|
||||||
# # image_key='rg.jpg'
|
# # image_key='rg.jpg'
|
||||||
# )
|
# )
|
||||||
cookies = '{"c_user":"61565823476070","datr":"q13hZowje6bbViFxECQpYyp8","fr":"01C6Lt4VArm5hELvx.AWXg75HOo-QNJgbiDl8qFtw_5lc.Bm4V2r..AAA.0.0.Bm4V25.AWWHzUeMTuI","m_pixel_ratio":"1.875","sb":"q13hZgJARsRIDmNJG8xUauAe","wd":"384x686","xs":"50%3A8luhgQ-Ea0vnhg%3A2%3A1726045627%3A-1%3A-1"}'
|
# cookies = '{"c_user":"61565823476070","datr":"q13hZowje6bbViFxECQpYyp8","fr":"01C6Lt4VArm5hELvx.AWXg75HOo-QNJgbiDl8qFtw_5lc.Bm4V2r..AAA.0.0.Bm4V25.AWWHzUeMTuI","m_pixel_ratio":"1.875","sb":"q13hZgJARsRIDmNJG8xUauAe","wd":"384x686","xs":"50%3A8luhgQ-Ea0vnhg%3A2%3A1726045627%3A-1%3A-1"}'
|
||||||
playwright_check_account_cookies(cookies)
|
# playwright_check_account_cookies(cookies)
|
||||||
# cookies = playwright_login('61575694132528', '@Badhon@20', 'LK3UVPADNOEGWIWPBAWWVGDPCMJOZN7M')
|
cookies = playwright_login('61575975148121', 'Mu1711rstu1999', 'JNCCTXB34EP5ME6RU6RND6SHBQ6KATAR')
|
||||||
# print(cookies)
|
# print(cookies)
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user