parent
2930f7d935
commit
e9a3a80012
177
main.py
177
main.py
|
@ -104,7 +104,7 @@ def generate_user_agent():
|
||||||
return user_agent
|
return user_agent
|
||||||
|
|
||||||
|
|
||||||
def random_sleep(tab, min_seconds=1, max_seconds=3):
|
def random_sleep(tab, min_seconds=0, max_seconds=2):
|
||||||
"""在 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,10 +467,11 @@ def click_use_other_account_button2(tab, next_span):
|
||||||
|
|
||||||
|
|
||||||
# 修改辅助邮箱账号
|
# 修改辅助邮箱账号
|
||||||
def modify_the_secondary_email1(tab, button, auxiliary_email_account):
|
def modify_the_secondary_email1(tab, 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 = button
|
input = tab.ele('@type=email', timeout=15)
|
||||||
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
|
||||||
|
@ -753,12 +754,33 @@ 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: # 加锁,确保其他进程在解锁前无法操作
|
||||||
|
@ -852,25 +874,19 @@ 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)
|
||||||
|
|
||||||
login = tab.ele('@@tag()=span@@text()=登录', timeout=10)
|
tab.wait(3)
|
||||||
if login:
|
|
||||||
random_sleep(tab)
|
|
||||||
# 将随机数设置为窗口标题
|
# 将随机数设置为窗口标题
|
||||||
script = f"document.title = '{random_number}';"
|
script = f"document.title = '{random_number}';"
|
||||||
# 执行 JS 脚本
|
# 执行 JS 脚本
|
||||||
tab.run_js(script)
|
tab.run_js(script)
|
||||||
|
actual_title = tab.run_js("return document.title;")
|
||||||
|
|
||||||
print("登录运行完毕")
|
print("登录运行完毕")
|
||||||
save_log(random_number, "已经进入登录界面")
|
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)
|
tab.wait(7)
|
||||||
|
|
||||||
actual_title = tab.run_js("return document.title;")
|
|
||||||
|
|
||||||
save_log(random_number, f"设置标题为: {random_number}, 实际标题为: {actual_title}\n")
|
save_log(random_number, f"设置标题为: {random_number}, 实际标题为: {actual_title}\n")
|
||||||
|
|
||||||
|
@ -1016,6 +1032,30 @@ 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
|
||||||
|
|
||||||
|
@ -1027,7 +1067,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=10) == False:
|
if tab.wait.ele_deleted('#passwordNext', timeout=5) == 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
|
||||||
|
@ -1045,31 +1085,10 @@ 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)
|
||||||
|
@ -1100,11 +1119,10 @@ def main(email_account, email_password, old_recovery_email, new_password, new_re
|
||||||
print("我要开始修改辅助邮箱账号了")
|
print("我要开始修改辅助邮箱账号了")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
button = tab.ele('@type=email', timeout=15)
|
button = tab.ele('@@tag()=i@@text()=edit', timeout=15)
|
||||||
if button:
|
if button:
|
||||||
modify_the_secondary_email1(tab,button, new_recovery_email) # 使用传入的新辅助邮箱
|
modify_the_secondary_email1(tab, new_recovery_email) # 使用传入的新辅助邮箱
|
||||||
print("修改完成")
|
print("修改完成")
|
||||||
auxiliary_email_account_change = True
|
|
||||||
else:
|
else:
|
||||||
print("没有修改辅助邮箱的界面,跳过")
|
print("没有修改辅助邮箱的界面,跳过")
|
||||||
# auxiliary_email_account_change = True
|
# auxiliary_email_account_change = True
|
||||||
|
@ -1128,25 +1146,24 @@ 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)
|
continue_div1 = tab.ele('@text()=Continue with smart features', timeout=15)
|
||||||
# if continue_div1:
|
if continue_div1:
|
||||||
# try:
|
try:
|
||||||
# click_continue_button(tab, continue_div1)
|
click_continue_button(tab, continue_div1)
|
||||||
# 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}")
|
||||||
# update_status_in_db(email_account, "请求错误,请重试")
|
update_status_in_db(email_account, "请求错误,请重试")
|
||||||
# return (
|
return (
|
||||||
# email_account, email_password, old_recovery_email, new_password, new_recovery_email, proxy_host,
|
email_account, email_password, old_recovery_email, new_password, new_recovery_email, proxy_host,
|
||||||
# proxy_port,
|
proxy_port,
|
||||||
# proxy_username, proxy_password, region)
|
proxy_username, proxy_password, region)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# 安全设置
|
# 安全设置
|
||||||
|
@ -1155,6 +1172,7 @@ 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 (
|
||||||
|
@ -1169,10 +1187,6 @@ 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)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# 如果密码没被修改
|
# 如果密码没被修改
|
||||||
|
@ -1197,7 +1211,6 @@ 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
|
||||||
|
@ -1205,7 +1218,6 @@ 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:
|
||||||
|
@ -1267,10 +1279,8 @@ 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, "已更改")
|
||||||
return email_account
|
break
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# 如果未找到验证码,点击重新发送按钮并进入下一次循环
|
# 如果未找到验证码,点击重新发送按钮并进入下一次循环
|
||||||
print("未找到验证码,点击重新发送按钮")
|
print("未找到验证码,点击重新发送按钮")
|
||||||
|
@ -1494,35 +1504,7 @@ 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))
|
||||||
|
@ -1600,6 +1582,11 @@ 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("程序控制界面")
|
||||||
|
|
||||||
|
@ -1643,6 +1630,8 @@ 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()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue