feat: add headless mode to login tool; add multi-view generation
This commit is contained in:
@@ -3,9 +3,10 @@
|
||||
腾讯混元3D 邮箱验证码登录 CLI 工具 (CloakBrowser 持久化版本)
|
||||
第一次输入邮箱回车后自动发送验证码
|
||||
第二次输入验证码后回车自动点击登录按钮
|
||||
登录状态会自动保存到 ./hunyuan3d_profile,下次运行无需重新登录
|
||||
登录状态会自动保存到 ~/.config/hunyuan3dweb/profile,下次运行无需重新登录
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
@@ -35,8 +36,18 @@ def _extract_and_save_cookies(context):
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="腾讯混元3D 邮箱验证码登录")
|
||||
parser.add_argument(
|
||||
"--no-headless",
|
||||
action="store_true",
|
||||
help="显示浏览器窗口(默认无头模式,适用于服务器)"
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
headless = not args.no_headless
|
||||
|
||||
# 使用持久化上下文,cookie 和登录状态会保存到 PROFILE_DIR
|
||||
context = launch_persistent_context(PROFILE_DIR, headless=False)
|
||||
context = launch_persistent_context(PROFILE_DIR, headless=headless)
|
||||
page = context.new_page()
|
||||
|
||||
print("正在打开腾讯混元3D...")
|
||||
@@ -48,6 +59,11 @@ def main():
|
||||
if login_btn.count() == 0:
|
||||
print("检测到已有登录状态,无需重新登录。")
|
||||
print(f"当前页面: {page.url}")
|
||||
_extract_and_save_cookies(context)
|
||||
|
||||
if headless:
|
||||
context.close()
|
||||
return
|
||||
else:
|
||||
# 未登录,走登录流程
|
||||
login_btn.click()
|
||||
@@ -125,9 +141,10 @@ def main():
|
||||
except Exception:
|
||||
print("\n登录可能仍在处理中,或出现错误。请检查浏览器状态。")
|
||||
|
||||
# 保持浏览器打开
|
||||
print("\n按 Enter 键关闭浏览器并退出...")
|
||||
input()
|
||||
# 保持浏览器打开(仅非无头模式)
|
||||
if not headless:
|
||||
print("\n按 Enter 键关闭浏览器并退出...")
|
||||
input()
|
||||
context.close()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user