try_a1_no_geetest.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. """Try A1 login directly — see if 996box needs geetest or not this time."""
  2. import asyncio
  3. import sys
  4. from pathlib import Path
  5. _HERE = Path(__file__).resolve().parent
  6. sys.path.insert(0, str(_HERE.parent / "src"))
  7. from cq2_sdk.env_loader import load_env
  8. load_env(_HERE.parent / ".env")
  9. from cq2_sdk.login import Box996Login, CaptchaRequiredError, ManualGeetestSolver
  10. from cq2_sdk.store import UserStore, connection
  11. ACCOUNT = "longwu988"
  12. PASSWORD = "Longwu1988"
  13. DEVICE_ID = "00:15:5d:0a:04:00"
  14. async def main() -> int:
  15. box = Box996Login(geetest=ManualGeetestSolver(), device_id=DEVICE_ID)
  16. try:
  17. print("trying login_with_password (no captcha)...")
  18. session = await box.login_with_password(ACCOUNT, PASSWORD)
  19. print(f"[OK] no geetest needed! got session:")
  20. print(f" uid = {session.uid}")
  21. print(f" token = {session.token[:30]}...")
  22. # Save to MySQL
  23. with connection() as conn:
  24. u = UserStore(conn).upsert_by_username(ACCOUNT, session.token)
  25. print(f"[OK] saved to MySQL users table, id={u.id}")
  26. return 0
  27. except CaptchaRequiredError as e:
  28. print(f"[BLOCKED] 996box requires geetest this time: {e}")
  29. print(" → can't proceed without your manual slide")
  30. return 1
  31. except Exception as e:
  32. print(f"[ERROR] {type(e).__name__}: {e}")
  33. return 2
  34. if __name__ == "__main__":
  35. sys.exit(asyncio.run(main()))