Files
ai_xhs/main.py
2025-12-08 15:27:00 +08:00

31 lines
1.0 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.

# -*- coding: utf-8 -*-
"""
main.py - 支持扫码登录和 cookie 登录模式选择
"""
import os
def main():
print("请选择登录模式:")
print("1. 扫码登录(首次登录/刷新 cookie")
print("2. 使用已保存 cookie 自动发文")
choice = input("请输入模式编号1或2").strip()
if choice == '1':
from scan_qrcode import scan_qrcode
scan_qrcode()
elif choice == '2':
cookie_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'cookies.json')
if not os.path.exists(cookie_path):
print("未检测到 cookie 文件,请先扫码登录!")
return
from use_cookie import get_test_content, auto_publish_xhs
title, desc, image_list = get_test_content()
if not image_list:
print('未找到图片文件请将图片放入test文件夹')
else:
auto_publish_xhs(title, desc, image_list)
else:
print("输入无效,请输入 1 或 2")
if __name__ == "__main__":
main()