最近用小红书的算法做了一个检测软件,效果如图
下面上简单的代码,
导入cookie文件代码
# 如果需要可联系Mkk2328
# 如果需要可联系Mkk2328
def import_file(self):
file_path = filedialog.askopenfilename(filetypes=[("文本文件", "*.txt")])
if file_path:
with open(file_path, 'r', encoding='utf-8') as f:
cookies = f.read().strip().split('\n')
# 新增:更新导入的Cookie行数标签
self.import_count_label.config(text=f"导入Cookie行数: {len(cookies)}")
for i, cookie in enumerate(cookies):
self.tree.insert("", "end", values=(i + 1, cookie, "待验证", "", "", ""))
def write_file_content(self,path, content, type):
parent_path = os.path.abspath(os.path.join(path, ".."))
# 如果上级文件夹不存在,则创建
if not os.path.exists(parent_path):
os.makedirs(parent_path)
# 如果文件不存在,则创建
if not os.path.isfile(path):
f = open(path, 'w')
f.close()
with open(path, mode=type) as file:
if type == "w":
file.write(content)
else:
file.write(content)
def on_closing(self):
self.running = False
self.is_logged_in = False
self.executor.shutdown(wait=False)
self.root.destroy()