53 lines
1.2 KiB
Python
53 lines
1.2 KiB
Python
|
#!/usr/bin/env python
|
|||
|
# -*- coding: UTF-8 -*-
|
|||
|
"""
|
|||
|
@Project :redbook
|
|||
|
@File :config.py
|
|||
|
@IDE :PyCharm
|
|||
|
@Author :rengengchen
|
|||
|
@Time :2024/4/17 16:42
|
|||
|
"""
|
|||
|
import os
|
|||
|
import sys
|
|||
|
|
|||
|
|
|||
|
def resource_path(relative_path):
|
|||
|
""" 获取资源的绝对路径。用于访问打包环境中的资源文件。 """
|
|||
|
try:
|
|||
|
# PyInstaller 创建的临时文件夹
|
|||
|
base_path = sys._MEIPASS
|
|||
|
except Exception:
|
|||
|
# 正常运行时的路径
|
|||
|
base_path = os.path.abspath(".")
|
|||
|
|
|||
|
return os.path.join(base_path, relative_path)
|
|||
|
|
|||
|
|
|||
|
HEAD = {
|
|||
|
'Host': 'edith.xiaohongshu.com',
|
|||
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome...',
|
|||
|
}
|
|||
|
INFO_COLUMNS = ['nickname', 'content', 'id', 'user_id', 'status', 'liked', 'create_time', 'note_id']
|
|||
|
RESULT_COLUMNS = ['nickname', 'content', 'ip_location', 'level', 'user_id', 'status', 'liked', 'create_time', 'note_id',
|
|||
|
'id']
|
|||
|
KEYWORDS = []
|
|||
|
RESULT_PATH = os.path.abspath('./')
|
|||
|
ENCODING = 'gbk'
|
|||
|
|
|||
|
|
|||
|
def modify_result_path(v):
|
|||
|
global RESULT_PATH
|
|||
|
RESULT_PATH = v
|
|||
|
|
|||
|
|
|||
|
def modify_filter_words(v):
|
|||
|
global KEYWORDS
|
|||
|
for v1 in v:
|
|||
|
if v1:
|
|||
|
KEYWORDS.append(v1)
|
|||
|
|
|||
|
|
|||
|
def modify_encoding(v):
|
|||
|
global ENCODING
|
|||
|
ENCODING = v
|