去除并发, 更改验证码识别密钥不存验证码图片
This commit is contained in:
@@ -1170,6 +1170,7 @@ def get_login_continue_btn(page):
|
||||
|
||||
|
||||
def playwright_login(username, password, code_2fa=None):
|
||||
error_logger.info(f"登录账号{username}")
|
||||
# 检查是否冻结
|
||||
check_freeze_account(username)
|
||||
|
||||
@@ -1210,19 +1211,17 @@ def playwright_login(username, password, code_2fa=None):
|
||||
page.reload()
|
||||
time.sleep(random.randint(1, 3))
|
||||
|
||||
captcha_img = page.query_selector_all('//img[contains(@src, "captcha")]')
|
||||
captcha_img = page.query_selector('//img[contains(@src, "captcha")]')
|
||||
if captcha_img:
|
||||
img_file_path = os.path.join(BASE_PATH, 'files', 'captcha.png')
|
||||
captcha_img[0].screenshot(path=img_file_path)
|
||||
with open(img_file_path, 'rb') as f:
|
||||
data = {
|
||||
'user': 'shaowz',
|
||||
'pass2': '69e86586e8a1241719ebacecf7bb84c2',
|
||||
'softid': '951004',
|
||||
'codetype': '3006',
|
||||
}
|
||||
response = requests.post('http://upload.chaojiying.net/Upload/Processing.php',
|
||||
data=data, timeout=60, files={'userfile': f})
|
||||
error_logger.info(f"账号{username} 需要验证")
|
||||
data = {
|
||||
'user': 'ycxxkj',
|
||||
'pass2': 'B4DBF06831577C6558F823879061626C',
|
||||
'softid': '951004',
|
||||
'codetype': '3006',
|
||||
}
|
||||
response = requests.post('http://upload.chaojiying.net/Upload/Processing.php', data=data,
|
||||
timeout=60, files={'userfile': ('ccc.jpg', captcha_img.screenshot())})
|
||||
result = response.json()
|
||||
if result['err_no'] == 0:
|
||||
pic_str = result['pic_str']
|
||||
@@ -1243,6 +1242,7 @@ def playwright_login(username, password, code_2fa=None):
|
||||
]
|
||||
|
||||
if not h2.text_content() in text_contexts:
|
||||
error_logger.info(f"账号{username} 操作失败")
|
||||
raise OperationFailed("操作失败")
|
||||
auth_span = page.query_selector('//span[text()="Try Another Way" or text()="Try another way"]')
|
||||
if auth_span:
|
||||
@@ -1261,8 +1261,8 @@ def playwright_login(username, password, code_2fa=None):
|
||||
time.sleep(1)
|
||||
page.locator('//label[text()="Code"]/preceding-sibling::input').fill(auth_code)
|
||||
page.click('//span[text()="Continue"]')
|
||||
# 这里验证可能会很慢, 做显示等待
|
||||
time.sleep(10)
|
||||
# 这里验证可能会很慢, 硬等
|
||||
time.sleep(40)
|
||||
save_profile = page.query_selector('//span[text()="Save"]')
|
||||
if save_profile:
|
||||
save_profile.click()
|
||||
|
||||
Reference in New Issue
Block a user