# -*- 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()