使用Selenium Python+2captcha开发Outlook账号创建器遇Funcaptcha问题求助
问题修复和实现方案
现存问题
- 你当前的unicaps调用逻辑错误,将solver实例直接覆盖为求解结果,导致后续逻辑无法执行
- 未填写2captcha的有效API密钥,请求会直接被拒绝
- 缺少验证码结果回填页面的逻辑,即使求解成功也无法完成验证
- Outlook站点的Funcaptcha需要额外传入
surl参数,仅传入公钥和页面地址无法正常求解
方案1:修复现有unicaps调用
修改验证码部分代码如下,注意替换为你自己的2captcha API密钥:
# unicaps 验证码求解部分 solver = CaptchaSolver(CaptchaSolvingService.TWOCAPTCHA, api_key="替换为你的2captcha API密钥") # 校验账户余额 balance = solver.get_balance() if balance < 0.001: print("2captcha账户余额不足") GChrome.quit() continue # 提交Funcaptcha求解请求 captcha_response = solver.solve_funcaptcha( public_key="B7D8911C-5CC8-A9A3-35B0-554ACEE604DA", page_url="https://signup.live.com/signup", surl="https://client-api.arkoselabs.com" ) # 回填验证码token到页面 token = captcha_response.solution.token GChrome.execute_script(f'document.querySelector(\'[name="fc-token"]\').value = "{token}"') # 提交验证 GChrome.find_element_by_id("iSignupAction").click()
方案2:直接使用官方2captcha-python库(更稳定)
无需依赖unicaps,直接用你已安装的官方库实现,兼容性更好:
# 官方2captcha库实现部分 from twocaptcha import TwoCaptcha solver = TwoCaptcha(api_key="替换为你的2captcha API密钥") try: result = solver.funcaptcha( sitekey="B7D8911C-5CC8-A9A3-35B0-554ACEE604DA", url="https://signup.live.com/signup", surl="https://client-api.arkoselabs.com" ) # 回填token token = result["code"] GChrome.execute_script(f'document.querySelector(\'[name="fc-token"]\').value = "{token}"') GChrome.find_element_by_id("iSignupAction").click() except Exception as e: print(f"验证码求解失败: {str(e)}") GChrome.quit() continue
额外优化建议
- 你当前使用的
find_element_by_*是Selenium旧版语法,若你使用Selenium 4.0+版本,建议替换为find_element(By.属性, 值)的写法,避免运行报错 - 将固定的
time.sleep替换为WebDriverWait显式等待,只在页面元素加载完成后执行操作,大幅提升流程稳定性 - 同一IP短时间内多次注册Outlook账号会触发风控,建议搭配代理池使用,同时增加重试逻辑处理验证码求解失败的情况
内容的提问来源于stack exchange,提问作者anon
相关产品推荐
相关产品推荐

