parent
e9a3a80012
commit
bc3b45acd7
189
main.py
189
main.py
|
@ -104,7 +104,7 @@ def generate_user_agent():
|
||||||
return user_agent
|
return user_agent
|
||||||
|
|
||||||
|
|
||||||
def random_sleep(tab, min_seconds=0, max_seconds=2):
|
def random_sleep(tab, min_seconds=1, max_seconds=3):
|
||||||
"""在 min_seconds 和 max_seconds 之间随机停顿"""
|
"""在 min_seconds 和 max_seconds 之间随机停顿"""
|
||||||
tab.wait(random.uniform(min_seconds, max_seconds))
|
tab.wait(random.uniform(min_seconds, max_seconds))
|
||||||
|
|
||||||
|
@ -467,11 +467,10 @@ def click_use_other_account_button2(tab, next_span):
|
||||||
|
|
||||||
|
|
||||||
# 修改辅助邮箱账号
|
# 修改辅助邮箱账号
|
||||||
def modify_the_secondary_email1(tab, auxiliary_email_account):
|
def modify_the_secondary_email1(tab, button, auxiliary_email_account):
|
||||||
button = tab.ele('@@tag()=i@@text()=edit', timeout=15)
|
|
||||||
button.click(by_js=True)
|
button.click(by_js=True)
|
||||||
tab.wait(2)
|
tab.wait(2)
|
||||||
input = tab.ele('@type=email', timeout=15)
|
input = button
|
||||||
input.clear()
|
input.clear()
|
||||||
for char in auxiliary_email_account:
|
for char in auxiliary_email_account:
|
||||||
input.input(char) # Enter one character at a time
|
input.input(char) # Enter one character at a time
|
||||||
|
@ -754,33 +753,12 @@ def main(email_account, email_password, old_recovery_email, new_password, new_re
|
||||||
print("任务被强制停止,退出主函数")
|
print("任务被强制停止,退出主函数")
|
||||||
return None # 直接返回 None,跳过当前任务
|
return None # 直接返回 None,跳过当前任务
|
||||||
|
|
||||||
if not region:
|
|
||||||
region = "ALL" # 如果没有区域信息,则使用默认区域
|
|
||||||
|
|
||||||
# 获取一个随机代理并传递给当前账号
|
|
||||||
proxy = proxy_manager.get_random_proxy_by_region(region=region, remove_after_fetch=True)
|
|
||||||
|
|
||||||
if proxy: # 如果分配成功
|
|
||||||
proxy_host, proxy_port, proxy_user, proxy_pass = proxy['host'], proxy['port'], proxy['user'], \
|
|
||||||
proxy['password']
|
|
||||||
print(f"为账号 {email_account} 分配代理:{proxy_host}:{proxy_port}:{proxy_user}:{proxy_pass}")
|
|
||||||
|
|
||||||
db_manager.update_record(email_account,proxy=f"{proxy_host}:{proxy_port}:{proxy_user}:{proxy_pass}")
|
|
||||||
else:
|
|
||||||
print(f"为账号 {email_account} 分配代理失败,跳过此账号。")
|
|
||||||
|
|
||||||
with write_lock:
|
|
||||||
try:
|
|
||||||
print("更新剩余可用IP")
|
|
||||||
proxy_manager.export_proxies("剩下的可用IP.txt")
|
|
||||||
except Exception as e:
|
|
||||||
print(f"导出代理时发生错误: {e}")
|
|
||||||
|
|
||||||
if not proxy_host:
|
if not proxy_host:
|
||||||
save_log(random_number, f"没有{region}区域的代理")
|
save_log(random_number, f"没有{region}区域的代理")
|
||||||
update_status_in_db(email_account, f"没有{region}区域代理")
|
update_status_in_db(email_account, f"没有{region}区域代理")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
lock = FileLock("proxy_auth_extension.lock")
|
lock = FileLock("proxy_auth_extension.lock")
|
||||||
|
|
||||||
with lock: # 加锁,确保其他进程在解锁前无法操作
|
with lock: # 加锁,确保其他进程在解锁前无法操作
|
||||||
|
@ -874,20 +852,26 @@ def main(email_account, email_password, old_recovery_email, new_password, new_re
|
||||||
click_the_login_button(tab, login_a)
|
click_the_login_button(tab, login_a)
|
||||||
random_sleep(tab)
|
random_sleep(tab)
|
||||||
|
|
||||||
tab.wait(3)
|
login = tab.ele('@@tag()=span@@text()=登录', timeout=10)
|
||||||
|
if login:
|
||||||
|
random_sleep(tab)
|
||||||
|
# 将随机数设置为窗口标题
|
||||||
|
script = f"document.title = '{random_number}';"
|
||||||
|
# 执行 JS 脚本
|
||||||
|
tab.run_js(script)
|
||||||
|
print("登录运行完毕")
|
||||||
|
save_log(random_number, "已经进入登录界面")
|
||||||
|
else:
|
||||||
|
update_status_in_db(email_account, '登录超时')
|
||||||
|
return (
|
||||||
|
email_account, email_password, old_recovery_email, new_password, new_recovery_email, proxy_host,
|
||||||
|
proxy_port,
|
||||||
|
proxy_username, proxy_password, region)
|
||||||
|
|
||||||
|
random_sleep(tab)
|
||||||
|
|
||||||
# 将随机数设置为窗口标题
|
|
||||||
script = f"document.title = '{random_number}';"
|
|
||||||
# 执行 JS 脚本
|
|
||||||
tab.run_js(script)
|
|
||||||
actual_title = tab.run_js("return document.title;")
|
actual_title = tab.run_js("return document.title;")
|
||||||
|
|
||||||
print("登录运行完毕")
|
|
||||||
save_log(random_number, "已经进入登录界面")
|
|
||||||
|
|
||||||
tab.wait(7)
|
|
||||||
|
|
||||||
save_log(random_number, f"设置标题为: {random_number}, 实际标题为: {actual_title}\n")
|
save_log(random_number, f"设置标题为: {random_number}, 实际标题为: {actual_title}\n")
|
||||||
|
|
||||||
# 获取所有 Chrome 窗口
|
# 获取所有 Chrome 窗口
|
||||||
|
@ -1032,30 +1016,6 @@ def main(email_account, email_password, old_recovery_email, new_password, new_re
|
||||||
print("如果出现错误,输入密码运行完毕")
|
print("如果出现错误,输入密码运行完毕")
|
||||||
save_log(random_number, "如果出现错误后,输入密码运行完毕")
|
save_log(random_number, "如果出现错误后,输入密码运行完毕")
|
||||||
|
|
||||||
|
|
||||||
# 看下是否出现了手机号
|
|
||||||
telephone = tab.ele("@text()=请输入电话号码,以便通过短信接收验证码。", timeout=5)
|
|
||||||
if telephone:
|
|
||||||
save_log(random_number, '接码')
|
|
||||||
update_status_in_db(email_account, '接码')
|
|
||||||
return email_account
|
|
||||||
|
|
||||||
print("检查手机号2运行完毕")
|
|
||||||
save_log(random_number, "检查手机号2运行完毕")
|
|
||||||
|
|
||||||
wrong = tab.ele('@@tag()=a@@text()=了解详情', timeout=5)
|
|
||||||
if wrong:
|
|
||||||
save_log(random_number, '出现账号状态异常')
|
|
||||||
update_status_in_db(email_account, '出现账号状态异常')
|
|
||||||
return (
|
|
||||||
email_account, email_password, old_recovery_email, new_password, new_recovery_email, proxy_host,
|
|
||||||
proxy_port,
|
|
||||||
proxy_username, proxy_password, region)
|
|
||||||
|
|
||||||
print("检查谷歌账号是否存在异常活动完毕")
|
|
||||||
save_log(random_number, "检查谷歌账号是否存在异常活动完毕")
|
|
||||||
|
|
||||||
|
|
||||||
# 确定密码是否被修改的开关
|
# 确定密码是否被修改的开关
|
||||||
password_change = False
|
password_change = False
|
||||||
|
|
||||||
|
@ -1067,7 +1027,7 @@ def main(email_account, email_password, old_recovery_email, new_password, new_re
|
||||||
input_password(tab, hwnd, new_password, password_input)
|
input_password(tab, hwnd, new_password, password_input)
|
||||||
save_log(random_number, f"输入新密码完毕")
|
save_log(random_number, f"输入新密码完毕")
|
||||||
tab.wait(7)
|
tab.wait(7)
|
||||||
if tab.wait.ele_deleted('#passwordNext', timeout=5) == False:
|
if tab.wait.ele_deleted('#passwordNext', timeout=10) == False:
|
||||||
update_status_in_db(email_account, '被盗')
|
update_status_in_db(email_account, '被盗')
|
||||||
return email_account
|
return email_account
|
||||||
password_change = True
|
password_change = True
|
||||||
|
@ -1085,10 +1045,31 @@ def main(email_account, email_password, old_recovery_email, new_password, new_re
|
||||||
print("输入新密码运行完毕")
|
print("输入新密码运行完毕")
|
||||||
save_log(random_number, "输入新密码运行完毕")
|
save_log(random_number, "输入新密码运行完毕")
|
||||||
|
|
||||||
|
# 看下是否出现了手机号
|
||||||
|
telephone = tab.ele("@text()=请输入电话号码,以便通过短信接收验证码。", timeout=5)
|
||||||
|
if telephone:
|
||||||
|
save_log(random_number, '接码')
|
||||||
|
update_status_in_db(email_account, '接码')
|
||||||
|
return email_account
|
||||||
|
|
||||||
|
print("检查手机号2运行完毕")
|
||||||
|
save_log(random_number, "检查手机号2运行完毕")
|
||||||
|
|
||||||
|
wrong = tab.ele('@@tag()=a@@text()=了解详情', timeout=5)
|
||||||
|
alternate_email_button = tab.ele('@text()=确认您的辅助邮箱', timeout=5)
|
||||||
|
if wrong and not alternate_email_button:
|
||||||
|
save_log(random_number, '出现账号状态异常')
|
||||||
|
update_status_in_db(email_account, '出现账号状态异常')
|
||||||
|
return (
|
||||||
|
email_account, email_password, old_recovery_email, new_password, new_recovery_email, proxy_host,
|
||||||
|
proxy_port,
|
||||||
|
proxy_username, proxy_password, region)
|
||||||
|
|
||||||
|
print("检查谷歌账号是否存在异常活动完毕")
|
||||||
|
save_log(random_number, "检查谷歌账号是否存在异常活动完毕")
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# 使用辅助邮箱验证
|
|
||||||
alternate_email_button = tab.ele('@text()=确认您的辅助邮箱', timeout=15)
|
|
||||||
if alternate_email_button:
|
if alternate_email_button:
|
||||||
click_alternate_email_verification_button(tab, alternate_email_button)
|
click_alternate_email_verification_button(tab, alternate_email_button)
|
||||||
random_sleep(tab)
|
random_sleep(tab)
|
||||||
|
@ -1119,10 +1100,11 @@ def main(email_account, email_password, old_recovery_email, new_password, new_re
|
||||||
print("我要开始修改辅助邮箱账号了")
|
print("我要开始修改辅助邮箱账号了")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
button = tab.ele('@@tag()=i@@text()=edit', timeout=15)
|
button = tab.ele('@type=email', timeout=15)
|
||||||
if button:
|
if button:
|
||||||
modify_the_secondary_email1(tab, new_recovery_email) # 使用传入的新辅助邮箱
|
modify_the_secondary_email1(tab,button, new_recovery_email) # 使用传入的新辅助邮箱
|
||||||
print("修改完成")
|
print("修改完成")
|
||||||
|
auxiliary_email_account_change = True
|
||||||
else:
|
else:
|
||||||
print("没有修改辅助邮箱的界面,跳过")
|
print("没有修改辅助邮箱的界面,跳过")
|
||||||
# auxiliary_email_account_change = True
|
# auxiliary_email_account_change = True
|
||||||
|
@ -1146,25 +1128,12 @@ def main(email_account, email_password, old_recovery_email, new_password, new_re
|
||||||
|
|
||||||
if password_change and auxiliary_email_account_change:
|
if password_change and auxiliary_email_account_change:
|
||||||
logutGoogle(tab)
|
logutGoogle(tab)
|
||||||
|
tab.wait(3)
|
||||||
update_status_in_db(email_account, '已更改')
|
update_status_in_db(email_account, '已更改')
|
||||||
return email_account
|
return email_account
|
||||||
|
|
||||||
tab.handle_alert(accept=True)
|
tab.handle_alert(accept=True)
|
||||||
|
|
||||||
# 点击继续按钮
|
|
||||||
continue_div1 = tab.ele('@text()=Continue with smart features', timeout=15)
|
|
||||||
if continue_div1:
|
|
||||||
try:
|
|
||||||
click_continue_button(tab, continue_div1)
|
|
||||||
except ElementNotFoundError as e:
|
|
||||||
print(f"找不到继续按钮的元素:{e}")
|
|
||||||
save_log(random_number, f"找不到继续按钮的元素:{e}")
|
|
||||||
update_status_in_db(email_account, "请求错误,请重试")
|
|
||||||
return (
|
|
||||||
email_account, email_password, old_recovery_email, new_password, new_recovery_email, proxy_host,
|
|
||||||
proxy_port,
|
|
||||||
proxy_username, proxy_password, region)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# 安全设置
|
# 安全设置
|
||||||
tab.handle_alert(accept=True)
|
tab.handle_alert(accept=True)
|
||||||
|
@ -1172,7 +1141,6 @@ def main(email_account, email_password, old_recovery_email, new_password, new_re
|
||||||
tab.handle_alert(accept=True)
|
tab.handle_alert(accept=True)
|
||||||
tab.get("https://myaccount.google.com/security?gar=WzEyMF0")
|
tab.get("https://myaccount.google.com/security?gar=WzEyMF0")
|
||||||
except ElementNotFoundError as e:
|
except ElementNotFoundError as e:
|
||||||
print(f"找不到头像的元素:{e}")
|
|
||||||
save_log(random_number, f"进入安全设置后出错:{e}")
|
save_log(random_number, f"进入安全设置后出错:{e}")
|
||||||
update_status_in_db(email_account,"进入安全设置的时候请求错误,请重试")
|
update_status_in_db(email_account,"进入安全设置的时候请求错误,请重试")
|
||||||
return (
|
return (
|
||||||
|
@ -1187,6 +1155,12 @@ def main(email_account, email_password, old_recovery_email, new_password, new_re
|
||||||
print("进入安全设置后仍然未登录")
|
print("进入安全设置后仍然未登录")
|
||||||
save_log(random_number, '进入安全设置后仍然未登录')
|
save_log(random_number, '进入安全设置后仍然未登录')
|
||||||
update_status_in_db(email_account, '登录失败')
|
update_status_in_db(email_account, '登录失败')
|
||||||
|
return (
|
||||||
|
email_account, email_password, old_recovery_email, new_password, new_recovery_email, proxy_host,
|
||||||
|
proxy_port,
|
||||||
|
proxy_username, proxy_password, region)
|
||||||
|
|
||||||
|
password_change_time1 = tab.ele("@text():Last changed").inner_html
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# 如果密码没被修改
|
# 如果密码没被修改
|
||||||
|
@ -1197,6 +1171,18 @@ def main(email_account, email_password, old_recovery_email, new_password, new_re
|
||||||
input_password_new(tab, new_password) # 使用传入的新密码
|
input_password_new(tab, new_password) # 使用传入的新密码
|
||||||
# 点击确认修改
|
# 点击确认修改
|
||||||
click_span_with_class(tab)
|
click_span_with_class(tab)
|
||||||
|
|
||||||
|
|
||||||
|
password_change_time2 = tab.ele("@text():Last changed").inner_html
|
||||||
|
if password_change_time2 != password_change_time1:
|
||||||
|
password_change = True
|
||||||
|
else:
|
||||||
|
save_log(random_number, '密码没有成功修改')
|
||||||
|
print("密码没有成功修改")
|
||||||
|
return (
|
||||||
|
email_account, email_password, old_recovery_email, new_password, new_recovery_email, proxy_host,
|
||||||
|
proxy_port,
|
||||||
|
proxy_username, proxy_password, region)
|
||||||
except ElementNotFoundError as e:
|
except ElementNotFoundError as e:
|
||||||
print(f"找不到修改密码的元素:{e}")
|
print(f"找不到修改密码的元素:{e}")
|
||||||
save_log(random_number, f"找不到修改密码的元素:{e}")
|
save_log(random_number, f"找不到修改密码的元素:{e}")
|
||||||
|
@ -1211,6 +1197,7 @@ def main(email_account, email_password, old_recovery_email, new_password, new_re
|
||||||
try:
|
try:
|
||||||
if auxiliary_email_account_change:
|
if auxiliary_email_account_change:
|
||||||
logutGoogle(tab)
|
logutGoogle(tab)
|
||||||
|
tab.wait(3)
|
||||||
update_status_in_db(email_account, '已更改')
|
update_status_in_db(email_account, '已更改')
|
||||||
return email_account
|
return email_account
|
||||||
# 修改辅助邮箱2
|
# 修改辅助邮箱2
|
||||||
|
@ -1218,6 +1205,7 @@ def main(email_account, email_password, old_recovery_email, new_password, new_re
|
||||||
save_log(random_number, f"辅助邮箱是否被修改:{flag}")
|
save_log(random_number, f"辅助邮箱是否被修改:{flag}")
|
||||||
if flag:
|
if flag:
|
||||||
logutGoogle(tab)
|
logutGoogle(tab)
|
||||||
|
tab.wait(3)
|
||||||
update_status_in_db(email_account, '已更改')
|
update_status_in_db(email_account, '已更改')
|
||||||
return email_account
|
return email_account
|
||||||
else:
|
else:
|
||||||
|
@ -1279,8 +1267,10 @@ def main(email_account, email_password, old_recovery_email, new_password, new_re
|
||||||
print("辅助邮箱账号已经更改完毕")
|
print("辅助邮箱账号已经更改完毕")
|
||||||
save_log(random_number, "辅助邮箱账号已经更改完毕")
|
save_log(random_number, "辅助邮箱账号已经更改完毕")
|
||||||
logutGoogle(tab)
|
logutGoogle(tab)
|
||||||
|
tab.wait(3)
|
||||||
update_status_in_db(email_account, "已更改")
|
update_status_in_db(email_account, "已更改")
|
||||||
break
|
return email_account
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# 如果未找到验证码,点击重新发送按钮并进入下一次循环
|
# 如果未找到验证码,点击重新发送按钮并进入下一次循环
|
||||||
print("未找到验证码,点击重新发送按钮")
|
print("未找到验证码,点击重新发送按钮")
|
||||||
|
@ -1504,7 +1494,35 @@ def run_gui():
|
||||||
print("停止信号已接收,中止任务!")
|
print("停止信号已接收,中止任务!")
|
||||||
break
|
break
|
||||||
|
|
||||||
|
# 获取邮箱和区域信息
|
||||||
|
account_email = row[0]
|
||||||
|
region = row[9] # 假设第6列存储的是账号的区域信息
|
||||||
|
|
||||||
|
if not region:
|
||||||
|
region = "ALL" # 如果没有区域信息,则使用默认区域
|
||||||
|
|
||||||
|
# 获取一个随机代理并传递给当前账号
|
||||||
|
proxy = proxy_manager.get_random_proxy_by_region(region=region, remove_after_fetch=True)
|
||||||
|
|
||||||
|
if proxy: # 如果分配成功
|
||||||
|
proxy_host, proxy_port, proxy_user, proxy_pass = proxy['host'], proxy['port'], proxy['user'], \
|
||||||
|
proxy['password']
|
||||||
|
print(f"为账号 {account_email} 分配代理:{proxy_host}:{proxy_port}:{proxy_user}:{proxy_pass}")
|
||||||
|
|
||||||
|
db_manager.update_record(account_email,
|
||||||
|
proxy=f"{proxy_host}:{proxy_port}:{proxy_user}:{proxy_pass}")
|
||||||
|
row = row[:5] + (proxy_host, proxy_port, proxy_user, proxy_pass) + row[9:] # 将代理信息加入到数据行中
|
||||||
|
else:
|
||||||
|
print(f"为账号 {account_email} 分配代理失败,跳过此账号。")
|
||||||
|
|
||||||
|
with write_lock:
|
||||||
|
try:
|
||||||
|
print("更新剩余可用IP")
|
||||||
|
proxy_manager.export_proxies("剩下的可用IP.txt")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"导出代理时发生错误: {e}")
|
||||||
|
|
||||||
|
update_proxy_stats()
|
||||||
|
|
||||||
# 传递锁给子进程,并将当前账号数据传递给 main 函数
|
# 传递锁给子进程,并将当前账号数据传递给 main 函数
|
||||||
result = pool.apply_async(main, args=(row), callback=lambda result: progress_queue.put(result))
|
result = pool.apply_async(main, args=(row), callback=lambda result: progress_queue.put(result))
|
||||||
|
@ -1582,11 +1600,6 @@ def run_gui():
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def periodic_update():
|
|
||||||
# 每隔一定时间调用一次更新代理统计信息的函数
|
|
||||||
update_proxy_stats()
|
|
||||||
root.after(5000, periodic_update) # 每5000毫秒(5秒)调用一次
|
|
||||||
|
|
||||||
root = tk.Tk()
|
root = tk.Tk()
|
||||||
root.title("程序控制界面")
|
root.title("程序控制界面")
|
||||||
|
|
||||||
|
@ -1630,8 +1643,6 @@ def run_gui():
|
||||||
lbl_proxy_stats = tk.Label(root, text="代理统计信息未加载")
|
lbl_proxy_stats = tk.Label(root, text="代理统计信息未加载")
|
||||||
lbl_proxy_stats.grid(row=8, column=1, padx=5, pady=10, columnspan=2)
|
lbl_proxy_stats.grid(row=8, column=1, padx=5, pady=10, columnspan=2)
|
||||||
|
|
||||||
periodic_update()
|
|
||||||
|
|
||||||
root.protocol("WM_DELETE_WINDOW", on_closing) # 绑定窗口关闭事件
|
root.protocol("WM_DELETE_WINDOW", on_closing) # 绑定窗口关闭事件
|
||||||
root.mainloop()
|
root.mainloop()
|
||||||
|
|
||||||
|
@ -1652,4 +1663,4 @@ if __name__ == "__main__":
|
||||||
os.remove(file_path)
|
os.remove(file_path)
|
||||||
|
|
||||||
freeze_support()
|
freeze_support()
|
||||||
run_gui()
|
run_gui()
|
Loading…
Reference in New Issue