去除并发, 更改验证码识别密钥不存验证码图片

This commit is contained in:
work
2025-05-26 10:44:16 +08:00
parent 2b857b2685
commit 24722b4363
2 changed files with 27 additions and 28 deletions

27
main.py
View File

@@ -23,8 +23,8 @@ def get_task():
'Content-Type': 'application/json' 'Content-Type': 'application/json'
} }
data = { data = {
"include_task_type": [], "include_task_type": ["login_account"],
"exclude_task_type": ["login_account"], "exclude_task_type": []
} }
response = requests.post(url, headers=header, json=data) response = requests.post(url, headers=header, json=data)
if response.status_code == 200: if response.status_code == 200:
@@ -61,19 +61,18 @@ def execute_task(tid, task_type, **kwargs):
def main(): def main():
with ThreadPoolExecutor(max_workers=1) as t: while True:
while True: try:
try: task = get_task()
task = get_task() if task is None:
if task is None:
time.sleep(10)
continue
task['data']['tid'] = task['id']
task['data']['task_type'] = task['task_type']
t.submit(execute_task, **task['data'])
except Exception as e:
error_logger.error(f'Main Error: {e}')
time.sleep(10) time.sleep(10)
continue
task['data']['tid'] = task['id']
task['data']['task_type'] = task['task_type']
execute_task(**task['data'])
except Exception as e:
error_logger.error(f'Main Error: {e}')
time.sleep(10)
if __name__ == '__main__': if __name__ == '__main__':

View File

@@ -1170,6 +1170,7 @@ def get_login_continue_btn(page):
def playwright_login(username, password, code_2fa=None): def playwright_login(username, password, code_2fa=None):
error_logger.info(f"登录账号{username}")
# 检查是否冻结 # 检查是否冻结
check_freeze_account(username) check_freeze_account(username)
@@ -1210,19 +1211,17 @@ def playwright_login(username, password, code_2fa=None):
page.reload() page.reload()
time.sleep(random.randint(1, 3)) 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: if captcha_img:
img_file_path = os.path.join(BASE_PATH, 'files', 'captcha.png') error_logger.info(f"账号{username} 需要验证")
captcha_img[0].screenshot(path=img_file_path) data = {
with open(img_file_path, 'rb') as f: 'user': 'ycxxkj',
data = { 'pass2': 'B4DBF06831577C6558F823879061626C',
'user': 'shaowz', 'softid': '951004',
'pass2': '69e86586e8a1241719ebacecf7bb84c2', 'codetype': '3006',
'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())})
response = requests.post('http://upload.chaojiying.net/Upload/Processing.php',
data=data, timeout=60, files={'userfile': f})
result = response.json() result = response.json()
if result['err_no'] == 0: if result['err_no'] == 0:
pic_str = result['pic_str'] 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: if not h2.text_content() in text_contexts:
error_logger.info(f"账号{username} 操作失败")
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:
@@ -1261,8 +1261,8 @@ def playwright_login(username, password, code_2fa=None):
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"]')
# 这里验证可能会很慢, 做显示等待 # 这里验证可能会很慢, 硬等
time.sleep(10) time.sleep(40)
save_profile = page.query_selector('//span[text()="Save"]') save_profile = page.query_selector('//span[text()="Save"]')
if save_profile: if save_profile:
save_profile.click() save_profile.click()