""" 快速测试脚本 - 一键运行测试 这个脚本会使用示例图片快速测试整个发布流程 """ import asyncio import sys from pathlib import Path # 添加路径 current_dir = Path(__file__).parent sys.path.insert(0, str(current_dir.parent)) from publisher import XiaoHongShuImageNote async def main(): """快速测试""" print("🚀 正在启动快速测试...") print() print("=" * 70) print("🧪 小红书笔记发布工具 - 快速测试") print("=" * 70) # 测试配置 title = "快速测试 ✨" content = "这是一条测试笔记" tags = ["#测试"] image_path = str(current_dir.parent / "videos" / "image.jpg") cookie_file = str(current_dir / "cookies" / "account.json") print(f"\n📋 测试配置:") print(f" 标题: {title}") print(f" 图片: {image_path}") print(f" 标签: {tags}") print(f" Cookie: {cookie_file}") # 检查图片 if not Path(image_path).exists(): print(f"\n❌ 测试图片不存在: {image_path}") print("💡 请确保 videos/image.jpg 文件存在") return # 创建Cookie目录 cookie_dir = Path(cookie_file).parent cookie_dir.mkdir(parents=True, exist_ok=True) print(f"\n✅ 环境检查通过") # 创建上传器 print(f"\n正在创建上传器...") note = XiaoHongShuImageNote( title=title, content=content, tags=tags, image_paths=[image_path], publish_date=0, account_file=cookie_file, headless=False ) print("✅ 上传器创建成功") print("\n💡 提示:") print(" - 浏览器会自动打开") print(" - 如果是首次使用,需要扫码登录") print(" - 整个过程约需30-60秒") print(" - 请勿手动操作浏览器\n") input("按回车键开始测试...") try: await note.main() print("\n" + "=" * 70) print("✅ 测试成功!笔记已发布到小红书!") print("=" * 70) print("\n📱 现在可以打开小红书App查看你的笔记了!") print("\n🎉 恭喜!你已成功完成快速测试!") print("\n📖 下一步:") print(" - 查看 example_image.py 学习更多图文笔记发布方法") print(" - 查看 example_video.py 学习视频笔记发布") print(" - 阅读 README.md 了解完整文档") except Exception as e: print("\n" + "=" * 70) print(f"❌ 测试失败: {e}") print("=" * 70) print("\n💡 故障排除建议:") print(" 1. 检查网络连接是否正常") print(" 2. 查看错误截图(如果有)") print(" 3. 阅读 README.md 的常见问题部分") if __name__ == "__main__": asyncio.run(main())