This commit is contained in:
2026-01-24 06:51:28 +08:00
parent 0e8b5ba237
commit 289e8ec71f
2 changed files with 65 additions and 20 deletions

1
.gitignore vendored
View File

@@ -33,3 +33,4 @@ Thumbs.db
nul nul
.claude/settings.local.json .claude/settings.local.json
autogptplus_drission.py

View File

@@ -621,14 +621,39 @@ def run_payment_flow(page, email, step_callback=None):
log_status("支付流程", "开始处理 Stripe 支付页...") log_status("支付流程", "开始处理 Stripe 支付页...")
try: try:
# 等待支付页加载完成(等待邮箱输入框出现) # 等待支付页加载完成
step_cb("等待支付页加载...") step_cb("等待支付页加载...")
log_status("支付页", "等待支付页加载...") 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("✓ 支付页已加载") log_progress("✓ 支付页已加载")
except: else:
time.sleep(2) # 兜底等待 log_progress("⚠ 邮箱输入框未立即出现,继续尝试...")
time.sleep(3)
# 随机选择 IBAN 和地址 # 随机选择 IBAN 和地址
ibans = get_sepa_ibans() ibans = get_sepa_ibans()
@@ -647,9 +672,16 @@ def run_payment_flow(page, email, step_callback=None):
step_cb("填写支付邮箱...") step_cb("填写支付邮箱...")
log_progress("[步骤1] 填写邮箱...") log_progress("[步骤1] 填写邮箱...")
try: 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: if not email_input:
log_progress("❌ 邮箱输入框未找到") log_progress("❌ 邮箱输入框未找到")
log_progress(f"当前URL: {page.url}")
return None return None
email_input.clear() email_input.clear()
email_input.input(email) email_input.input(email)
@@ -657,6 +689,7 @@ def run_payment_flow(page, email, step_callback=None):
time.sleep(1) time.sleep(1)
except Exception as e: except Exception as e:
log_progress(f"❌ 邮箱填写失败: {e}") log_progress(f"❌ 邮箱填写失败: {e}")
log_progress(f"当前URL: {page.url}")
return None return None
# ========== 步骤 2: 选择 SEPA ========== # ========== 步骤 2: 选择 SEPA ==========
@@ -1287,7 +1320,7 @@ def run_single_registration(progress_callback=None, step_callback=None) -> dict:
def log_cb(msg): def log_cb(msg):
if progress_callback: if progress_callback:
progress_callback(msg) progress_callback(msg)
print(msg) log_progress(msg)
def step_cb(step): def step_cb(step):
if step_callback: if step_callback:
@@ -1319,7 +1352,8 @@ def run_single_registration(progress_callback=None, step_callback=None) -> dict:
random.choice('!@#$%') random.choice('!@#$%')
real_name = f"{random.choice(FIRST_NAMES)} {random.choice(LAST_NAMES)}" 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" is_linux = platform.system() == "Linux"
@@ -1330,6 +1364,7 @@ def run_single_registration(progress_callback=None, step_callback=None) -> dict:
fingerprint = None fingerprint = None
if RANDOM_FINGERPRINT: if RANDOM_FINGERPRINT:
fingerprint = get_random_fingerprint() fingerprint = get_random_fingerprint()
log_status("指纹", f"已注入: {fingerprint['webgl_renderer'][:40]}...")
else: else:
fingerprint = { 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", "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("打开注册页面...") step_cb("打开注册页面...")
log_cb("打开 ChatGPT 注册页...") log_status("步骤 1/5", "打开 ChatGPT 注册页...")
page.get(TARGET_URL) page.get(TARGET_URL)
step_cb("点击登录按钮...") step_cb("点击登录按钮...")
@@ -1394,51 +1429,53 @@ def run_single_registration(progress_callback=None, step_callback=None) -> dict:
login_btn.click() login_btn.click()
step_cb("填写邮箱...") step_cb("填写邮箱...")
log_cb("填入邮箱...") log_progress("填入邮箱...")
email_input = page.ele('@name=email', timeout=30) email_input = page.ele('@name=email', timeout=30)
email_input.input(email) email_input.input(email)
page.ele('xpath://button[@type="submit"]').click() page.ele('xpath://button[@type="submit"]').click()
step_cb("填写密码...") step_cb("填写密码...")
log_cb("填入密码...") log_progress("填入密码...")
password_input = page.ele('xpath://input[@type="password"]', timeout=30) password_input = page.ele('xpath://input[@type="password"]', timeout=30)
password_input.input(password) password_input.input(password)
page.ele('xpath://button[@type="submit"]').click() page.ele('xpath://button[@type="submit"]').click()
step_cb("等待验证邮件...") step_cb("等待验证邮件...")
log_cb("等待验证邮件...") log_status("步骤 2/5", "等待邮件 (All Mail)...")
verify_data = get_verification_content(email) verify_data = get_verification_content(email)
if not verify_data: if not verify_data:
return {"success": False, "error": "未能获取验证码", "account": email, "password": password} return {"success": False, "error": "未能获取验证码", "account": email, "password": password}
step_cb("执行邮箱验证...") step_cb("执行邮箱验证...")
log_cb("执行验证...") log_status("步骤 3/5", "执行验证...")
if verify_data['type'] == 'link': if verify_data['type'] == 'link':
page.new_tab(verify_data['val']) page.new_tab(verify_data['val'])
time.sleep(5) time.sleep(5)
elif verify_data['type'] == 'code': elif verify_data['type'] == 'code':
code = verify_data['val'] 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 = page.ele('css:input[autocomplete="one-time-code"], input[name="code"], #code', timeout=15)
code_input.input(code) code_input.input(code)
time.sleep(1) time.sleep(1)
try: try:
log_progress("尝试点击继续按钮...")
continue_btn = page.ele('css:button[type="submit"]', timeout=5) continue_btn = page.ele('css:button[type="submit"]', timeout=5)
if continue_btn: if continue_btn:
continue_btn.click() continue_btn.click()
except: except:
pass log_progress("未找到按钮或已自动跳转...")
# 资料填写 # 资料填写
step_cb("填写个人信息...") step_cb("填写个人信息...")
log_cb("填写个人信息...") log_status("步骤 4/5", "进入信息填写页...")
name_input = page.ele('@name=name', timeout=20) name_input = page.ele('@name=name', timeout=20)
name_input.input(real_name) name_input.input(real_name)
page.actions.key_down('Tab').key_up('Tab') page.actions.key_down('Tab').key_up('Tab')
birth_year, birth_month, birth_day = generate_random_birthday() birth_year, birth_month, birth_day = generate_random_birthday()
birth_str = birth_year + birth_month + birth_day birth_str = birth_year + birth_month + birth_day
log_progress(f"生日: {birth_year}-{birth_month}-{birth_day}")
for digit in birth_str: for digit in birth_str:
page.actions.type(digit) page.actions.type(digit)
time.sleep(0.1) time.sleep(0.1)
@@ -1449,18 +1486,21 @@ def run_single_registration(progress_callback=None, step_callback=None) -> dict:
# 等待进入主页 # 等待进入主页
step_cb("等待进入主页...") step_cb("等待进入主页...")
log_cb("等待进入主页...") log_status("订阅", "等待进入 ChatGPT 主页...")
for _ in range(30): for _ in range(30):
current_url = page.url current_url = page.url
if 'chatgpt.com' in current_url and 'auth' not in current_url and 'login' not in current_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 break
time.sleep(1) time.sleep(1)
else:
log_progress("⚠ 等待主页超时,尝试继续...")
time.sleep(3) time.sleep(3)
# 跳转到支付页 # 跳转到支付页
step_cb("跳转到支付页...") step_cb("跳转到支付页...")
log_cb("跳转到支付页...") log_status("订阅", "执行 JS 跳转到支付页...")
checkout_js = ''' checkout_js = '''
(async function(){ (async function(){
try { try {
@@ -1484,20 +1524,22 @@ def run_single_registration(progress_callback=None, step_callback=None) -> dict:
} catch(e) { return "发生错误:" + e; } } catch(e) { return "发生错误:" + e; }
})(); })();
''' '''
page.run_js(checkout_js) result = page.run_js(checkout_js)
log_progress(f"JS 执行结果: {result}")
try: try:
page.wait.url_change('pay.openai.com', timeout=15) page.wait.url_change('pay.openai.com', timeout=15)
log_progress("✓ 已跳转到支付页")
except: except:
time.sleep(2) time.sleep(2)
# 执行支付流程 # 执行支付流程
step_cb("执行 SEPA 支付...") step_cb("执行 SEPA 支付...")
log_cb("执行支付流程...")
result = run_payment_flow(page, email, step_cb) result = run_payment_flow(page, email, step_cb)
if result and result.get("token"): if result and result.get("token"):
step_cb("注册成功!") step_cb("注册成功!")
log_status("完成", "✓ 注册成功!")
return { return {
"success": True, "success": True,
"account": email, "account": email,
@@ -1506,9 +1548,11 @@ def run_single_registration(progress_callback=None, step_callback=None) -> dict:
"account_id": result.get("account_id", "") "account_id": result.get("account_id", "")
} }
else: else:
log_status("失败", "注册失败: 支付流程失败")
return {"success": False, "error": "支付流程失败", "account": email, "password": password} return {"success": False, "error": "支付流程失败", "account": email, "password": password}
except Exception as e: except Exception as e:
log_status("错误", f"注册异常: {e}")
return {"success": False, "error": str(e), "account": email, "password": password} return {"success": False, "error": str(e), "account": email, "password": password}
finally: finally:
if page: if page: