test_xhs_paging.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/env python3
  2. """
  3. 测试小红书作品自动分页 - 直接调用 Python API
  4. """
  5. import asyncio
  6. import sys
  7. import json
  8. from platforms.xiaohongshu import XiaohongshuPublisher
  9. async def main():
  10. if len(sys.argv) < 2:
  11. print("用法: python test_xhs_paging.py <账号ID>")
  12. print("示例: python test_xhs_paging.py 35")
  13. sys.exit(1)
  14. account_id = sys.argv[1]
  15. # 从 Node.js 数据库读取账号信息
  16. # 这里我们需要手动提供 cookie,或者从数据库读取
  17. # 为了简化,我们先从 Node.js 获取 cookie
  18. print(f"测试账号 ID: {account_id}")
  19. print("=" * 60)
  20. print("注意: 此脚本需要从数据库读取账号的 Cookie")
  21. print("建议使用 Node.js 脚本 test-xhs-works-sync.ts 来测试")
  22. print("=" * 60)
  23. # 实际上,我们应该从 Node.js 获取 cookie
  24. # 但为了测试,我们可以直接调用 get_all_works
  25. # 这里需要手动提供 cookie JSON 字符串
  26. print("\n请使用 Node.js 脚本 test-xhs-works-sync.ts 来测试")
  27. print("它会自动调用 Python API 并显示详细日志")
  28. if __name__ == "__main__":
  29. asyncio.run(main())