117 lines
3.2 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
环球影城笔记测试
"""
import asyncio
import sys
from pathlib import Path
# 添加父目录到路径
current_dir = Path(__file__).parent
parent_dir = current_dir.parent
sys.path.insert(0, str(parent_dir))
from publisher import XiaoHongShuImageNote
async def main():
"""发布环球影城笔记"""
print("=" * 70)
print("🎬 环球影城笔记发布测试")
print("=" * 70)
# 标题
title = "环球影城双床房|标准价无早情侣入住指南"
# 正文
content = """想带她私奔到电影世界吗?🎬北京环球影城大酒店提供标准双床房型
✨【基础服务说明】
✅客房配置:标准双床房型(床型符合酒店标准配置)
✅入住权益:凭房卡正常时段入园
⚠️官方提示
❌酒店提供基础客房服务,具体房内装饰以实际为准
❌餐饮及园区活动请参考环球影城官方公告
📸实用建议
✔园区内有多处经典打卡点
✔建议穿着舒适鞋履游览
这个夏天,住进环球影城开启电影之旅~"""
# 标签完整的8个标签
tags = [
"#北京旅游",
"#北京周边游",
"#京津冀周末游",
"#环球影城大酒店",
"#环球影城攻略",
"#环球影城推荐",
"#周末去哪儿玩",
"#小众约会圣地"
]
# 图片路径
image_path = str(parent_dir / "videos" / "image.jpg")
# Cookie文件
cookie_file = str(current_dir / "cookies" / "account.json")
print(f"\n📋 测试内容:")
print(f" 标题: {title}")
print(f" 正文长度: {len(content)} 字符")
print(f" 标签: {', '.join(tags)}")
print(f" 图片: {image_path}")
print(f" Cookie: {cookie_file}")
# 检查图片
if not Path(image_path).exists():
print(f"\n❌ 图片文件不存在: {image_path}")
return
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秒\n")
input("按回车键开始发布...")
# 执行发布
try:
await note.main()
print("\n" + "=" * 70)
print("✅ 发布成功!环球影城笔记已发布到小红书!")
print("=" * 70)
print("\n📱 现在可以打开小红书App查看笔记了")
print("\n🎉 测试完成!")
except Exception as e:
print("\n" + "=" * 70)
print(f"❌ 发布失败: {e}")
print("=" * 70)
print("\n💡 故障排除建议:")
print(" 1. 检查网络连接")
print(" 2. 查看错误截图(如果有)")
print(" 3. 检查Cookie是否有效")
if __name__ == "__main__":
asyncio.run(main())