From 289e8ec71f9e22338d6a51336d99972f6c72d660 Mon Sep 17 00:00:00 2001 From: kyx236 Date: Sat, 24 Jan 2026 06:51:28 +0800 Subject: [PATCH] update --- .gitignore | 1 + auto_gpt_team.py | 84 ++++++++++++++++++++++++++++++++++++------------ 2 files changed, 65 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 622e340..5edfdb1 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ Thumbs.db nul .claude/settings.local.json +autogptplus_drission.py diff --git a/auto_gpt_team.py b/auto_gpt_team.py index 2eeaf74..c1fa043 100644 --- a/auto_gpt_team.py +++ b/auto_gpt_team.py @@ -621,14 +621,39 @@ def run_payment_flow(page, email, step_callback=None): log_status("支付流程", "开始处理 Stripe 支付页...") try: - # 等待支付页加载完成(等待邮箱输入框出现) + # 等待支付页加载完成 step_cb("等待支付页加载...") log_status("支付页", "等待支付页加载...") - try: - page.ele('#email', timeout=10) + + # 等待页面稳定(Stripe 支付页需要时间渲染) + time.sleep(3) + + # 尝试多种方式定位邮箱输入框 + email_input = None + for attempt in range(3): + # 方式1: 直接 ID + email_input = page.ele('#email', timeout=5) + if email_input: + break + + # 方式2: name 属性 + email_input = page.ele('@name=email', timeout=3) + if email_input: + break + + # 方式3: CSS 选择器 + email_input = page.ele('css:input[type="email"], input[id*="email"], input[name*="email"]', timeout=3) + if email_input: + break + + log_progress(f"[尝试{attempt+1}] 等待邮箱输入框...") + time.sleep(2) + + if email_input: log_progress("✓ 支付页已加载") - except: - time.sleep(2) # 兜底等待 + else: + log_progress("⚠ 邮箱输入框未立即出现,继续尝试...") + time.sleep(3) # 随机选择 IBAN 和地址 ibans = get_sepa_ibans() @@ -647,9 +672,16 @@ def run_payment_flow(page, email, step_callback=None): step_cb("填写支付邮箱...") log_progress("[步骤1] 填写邮箱...") try: - email_input = page.ele('#email', timeout=10) + # 如果之前已经找到了,直接使用;否则重新查找 + if not email_input: + email_input = page.ele('#email', timeout=10) + if not email_input: + email_input = page.ele('@name=email', timeout=5) + if not email_input: + email_input = page.ele('css:input[type="email"]', timeout=5) if not email_input: log_progress("❌ 邮箱输入框未找到") + log_progress(f"当前URL: {page.url}") return None email_input.clear() email_input.input(email) @@ -657,6 +689,7 @@ def run_payment_flow(page, email, step_callback=None): time.sleep(1) except Exception as e: log_progress(f"❌ 邮箱填写失败: {e}") + log_progress(f"当前URL: {page.url}") return None # ========== 步骤 2: 选择 SEPA ========== @@ -1287,7 +1320,7 @@ def run_single_registration(progress_callback=None, step_callback=None) -> dict: def log_cb(msg): if progress_callback: progress_callback(msg) - print(msg) + log_progress(msg) def step_cb(step): if step_callback: @@ -1319,7 +1352,8 @@ def run_single_registration(progress_callback=None, step_callback=None) -> dict: random.choice('!@#$%') real_name = f"{random.choice(FIRST_NAMES)} {random.choice(LAST_NAMES)}" - log_cb(f"生成账号: {email}") + log_status("初始化", f"生成账号: {email}") + log_status("初始化", f"设置密码: {password}") # 检测操作系统 is_linux = platform.system() == "Linux" @@ -1330,6 +1364,7 @@ def run_single_registration(progress_callback=None, step_callback=None) -> dict: fingerprint = None if RANDOM_FINGERPRINT: fingerprint = get_random_fingerprint() + log_status("指纹", f"已注入: {fingerprint['webgl_renderer'][:40]}...") else: fingerprint = { "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36", @@ -1384,7 +1419,7 @@ def run_single_registration(progress_callback=None, step_callback=None) -> dict: # 注册流程 step_cb("打开注册页面...") - log_cb("打开 ChatGPT 注册页...") + log_status("步骤 1/5", "打开 ChatGPT 注册页...") page.get(TARGET_URL) step_cb("点击登录按钮...") @@ -1394,51 +1429,53 @@ def run_single_registration(progress_callback=None, step_callback=None) -> dict: login_btn.click() step_cb("填写邮箱...") - log_cb("填入邮箱...") + log_progress("填入邮箱...") email_input = page.ele('@name=email', timeout=30) email_input.input(email) page.ele('xpath://button[@type="submit"]').click() step_cb("填写密码...") - log_cb("填入密码...") + log_progress("填入密码...") password_input = page.ele('xpath://input[@type="password"]', timeout=30) password_input.input(password) page.ele('xpath://button[@type="submit"]').click() step_cb("等待验证邮件...") - log_cb("等待验证邮件...") + log_status("步骤 2/5", "等待邮件 (All Mail)...") verify_data = get_verification_content(email) if not verify_data: return {"success": False, "error": "未能获取验证码", "account": email, "password": password} step_cb("执行邮箱验证...") - log_cb("执行验证...") + log_status("步骤 3/5", "执行验证...") if verify_data['type'] == 'link': page.new_tab(verify_data['val']) time.sleep(5) elif verify_data['type'] == 'code': code = verify_data['val'] - log_cb(f"填入验证码: {code}") + log_progress(f"填入验证码: {code}") code_input = page.ele('css:input[autocomplete="one-time-code"], input[name="code"], #code', timeout=15) code_input.input(code) time.sleep(1) try: + log_progress("尝试点击继续按钮...") continue_btn = page.ele('css:button[type="submit"]', timeout=5) if continue_btn: continue_btn.click() except: - pass + log_progress("未找到按钮或已自动跳转...") # 资料填写 step_cb("填写个人信息...") - log_cb("填写个人信息...") + log_status("步骤 4/5", "进入信息填写页...") name_input = page.ele('@name=name', timeout=20) name_input.input(real_name) page.actions.key_down('Tab').key_up('Tab') birth_year, birth_month, birth_day = generate_random_birthday() birth_str = birth_year + birth_month + birth_day + log_progress(f"生日: {birth_year}-{birth_month}-{birth_day}") for digit in birth_str: page.actions.type(digit) time.sleep(0.1) @@ -1449,18 +1486,21 @@ def run_single_registration(progress_callback=None, step_callback=None) -> dict: # 等待进入主页 step_cb("等待进入主页...") - log_cb("等待进入主页...") + log_status("订阅", "等待进入 ChatGPT 主页...") for _ in range(30): current_url = page.url if 'chatgpt.com' in current_url and 'auth' not in current_url and 'login' not in current_url: + log_progress(f"✓ 已进入主页: {current_url[:50]}...") break time.sleep(1) + else: + log_progress("⚠ 等待主页超时,尝试继续...") time.sleep(3) # 跳转到支付页 step_cb("跳转到支付页...") - log_cb("跳转到支付页...") + log_status("订阅", "执行 JS 跳转到支付页...") checkout_js = ''' (async function(){ try { @@ -1484,20 +1524,22 @@ def run_single_registration(progress_callback=None, step_callback=None) -> dict: } catch(e) { return "发生错误:" + e; } })(); ''' - page.run_js(checkout_js) + result = page.run_js(checkout_js) + log_progress(f"JS 执行结果: {result}") try: page.wait.url_change('pay.openai.com', timeout=15) + log_progress("✓ 已跳转到支付页") except: time.sleep(2) # 执行支付流程 step_cb("执行 SEPA 支付...") - log_cb("执行支付流程...") result = run_payment_flow(page, email, step_cb) if result and result.get("token"): step_cb("注册成功!") + log_status("完成", "✓ 注册成功!") return { "success": True, "account": email, @@ -1506,9 +1548,11 @@ def run_single_registration(progress_callback=None, step_callback=None) -> dict: "account_id": result.get("account_id", "") } else: + log_status("失败", "注册失败: 支付流程失败") return {"success": False, "error": "支付流程失败", "account": email, "password": password} except Exception as e: + log_status("错误", f"注册异常: {e}") return {"success": False, "error": str(e), "account": email, "password": password} finally: if page: