2024-10-19 16:43:25 +00:00
|
|
|
|
# 声明:本代码仅供学习和研究目的使用。使用者应遵守以下原则:
|
|
|
|
|
# 1. 不得用于任何商业用途。
|
|
|
|
|
# 2. 使用时应遵守目标平台的使用条款和robots.txt规则。
|
|
|
|
|
# 3. 不得进行大规模爬取或对平台造成运营干扰。
|
|
|
|
|
# 4. 应合理控制请求频率,避免给目标平台带来不必要的负担。
|
|
|
|
|
# 5. 不得用于任何非法或不当的用途。
|
|
|
|
|
#
|
|
|
|
|
# 详细许可条款请参阅项目根目录下的LICENSE文件。
|
|
|
|
|
# 使用本代码即表示您同意遵守上述原则和LICENSE中的所有条款。
|
|
|
|
|
|
|
|
|
|
|
2023-11-26 13:43:39 +00:00
|
|
|
|
# 基础配置
|
2023-06-27 15:38:30 +00:00
|
|
|
|
PLATFORM = "xhs"
|
2024-10-24 07:35:34 +00:00
|
|
|
|
KEYWORDS = "编程副业,编程兼职" # 关键词搜索配置,以英文逗号分隔
|
2023-07-30 13:30:26 +00:00
|
|
|
|
LOGIN_TYPE = "qrcode" # qrcode or phone or cookie
|
2023-11-26 13:43:39 +00:00
|
|
|
|
COOKIES = ""
|
2024-06-14 06:13:39 +00:00
|
|
|
|
# 具体值参见media_platform.xxx.field下的枚举值,暂时只支持小红书
|
2024-06-12 02:17:37 +00:00
|
|
|
|
SORT_TYPE = "popularity_descending"
|
2024-06-14 06:13:39 +00:00
|
|
|
|
# 具体值参见media_platform.xxx.field下的枚举值,暂时只支持抖音
|
|
|
|
|
PUBLISH_TIME_TYPE = 0
|
2024-04-05 02:44:05 +00:00
|
|
|
|
CRAWLER_TYPE = "search" # 爬取类型,search(关键词搜索) | detail(帖子详情)| creator(创作者主页数据)
|
2023-06-27 15:38:30 +00:00
|
|
|
|
|
2023-11-26 13:43:39 +00:00
|
|
|
|
# 是否开启 IP 代理
|
2023-12-08 16:06:57 +00:00
|
|
|
|
ENABLE_IP_PROXY = False
|
2023-12-07 16:10:04 +00:00
|
|
|
|
|
|
|
|
|
# 代理IP池数量
|
|
|
|
|
IP_PROXY_POOL_COUNT = 2
|
2023-06-27 15:38:30 +00:00
|
|
|
|
|
2024-04-05 02:44:05 +00:00
|
|
|
|
# 代理IP提供商名称
|
2024-04-17 15:12:05 +00:00
|
|
|
|
IP_PROXY_PROVIDER_NAME = "kuaidaili"
|
2024-04-05 02:44:05 +00:00
|
|
|
|
|
2024-05-12 15:28:50 +00:00
|
|
|
|
# 设置为True不会打开浏览器(无头浏览器)
|
|
|
|
|
# 设置False会打开一个浏览器
|
|
|
|
|
# 小红书如果一直扫码登录不通过,打开浏览器手动过一下滑动验证码
|
|
|
|
|
# 抖音如果一直提示失败,打开浏览器看下是否扫码登录之后出现了手机号验证,如果出现了手动过一下再试。
|
2024-05-23 14:15:14 +00:00
|
|
|
|
HEADLESS = False
|
2023-07-15 09:11:53 +00:00
|
|
|
|
|
2023-11-26 13:43:39 +00:00
|
|
|
|
# 是否保存登录状态
|
2023-07-24 12:59:43 +00:00
|
|
|
|
SAVE_LOGIN_STATE = True
|
2023-07-15 09:11:53 +00:00
|
|
|
|
|
2024-09-07 16:00:04 +00:00
|
|
|
|
# 数据保存类型选项配置,支持三种类型:csv、db、json, 最好保存到DB,有排重的功能。
|
|
|
|
|
SAVE_DATA_OPTION = "json" # csv or db or json
|
2024-01-14 14:06:31 +00:00
|
|
|
|
|
2023-11-26 13:43:39 +00:00
|
|
|
|
# 用户浏览器缓存的浏览器文件配置
|
2023-07-15 09:11:53 +00:00
|
|
|
|
USER_DATA_DIR = "%s_user_data_dir" # %s will be replaced by platform name
|
|
|
|
|
|
2024-04-11 16:52:47 +00:00
|
|
|
|
# 爬取开始页数 默认从第一页开始
|
|
|
|
|
START_PAGE = 1
|
|
|
|
|
|
2023-11-26 13:43:39 +00:00
|
|
|
|
# 爬取视频/帖子的数量控制
|
2024-10-24 07:35:34 +00:00
|
|
|
|
CRAWLER_MAX_NOTES_COUNT = 200
|
2023-07-15 14:25:56 +00:00
|
|
|
|
|
2023-11-26 13:43:39 +00:00
|
|
|
|
# 并发爬虫数量控制
|
2024-07-24 16:44:46 +00:00
|
|
|
|
MAX_CONCURRENCY_NUM = 1
|
2023-11-18 05:38:11 +00:00
|
|
|
|
|
2024-04-09 09:21:52 +00:00
|
|
|
|
# 是否开启爬图片模式, 默认不开启爬图片
|
2024-04-10 01:54:28 +00:00
|
|
|
|
ENABLE_GET_IMAGES = False
|
2024-04-09 09:21:52 +00:00
|
|
|
|
|
2024-10-16 13:02:27 +00:00
|
|
|
|
# 是否开启爬评论模式, 默认开启爬评论
|
2024-10-19 16:59:08 +00:00
|
|
|
|
ENABLE_GET_COMMENTS = True
|
2023-11-18 05:38:11 +00:00
|
|
|
|
|
2024-10-22 12:33:10 +00:00
|
|
|
|
# 爬取一级评论的数量控制(单视频/帖子)
|
|
|
|
|
CRAWLER_MAX_COMMENTS_COUNT_SINGLENOTES = 10
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-11 09:53:04 +00:00
|
|
|
|
# 是否开启爬二级评论模式, 默认不开启爬二级评论
|
2024-04-12 09:32:20 +00:00
|
|
|
|
# 老版本项目使用了 db, 则需参考 schema/tables.sql line 287 增加表字段
|
2024-08-08 06:19:32 +00:00
|
|
|
|
ENABLE_GET_SUB_COMMENTS = False
|
2024-04-11 09:16:13 +00:00
|
|
|
|
|
2024-10-19 16:59:08 +00:00
|
|
|
|
# 已废弃⚠️⚠️⚠️指定小红书需要爬虫的笔记ID列表
|
|
|
|
|
# 已废弃⚠️⚠️⚠️ 指定笔记ID笔记列表会因为缺少xsec_token和xsec_source参数导致爬取失败
|
|
|
|
|
# XHS_SPECIFIED_ID_LIST = [
|
|
|
|
|
# "66fad51c000000001b0224b8",
|
|
|
|
|
# # ........................
|
|
|
|
|
# ]
|
|
|
|
|
|
|
|
|
|
# 指定小红书需要爬虫的笔记URL列表, 目前要携带xsec_token和xsec_source参数
|
|
|
|
|
XHS_SPECIFIED_NOTE_URL_LIST = [
|
|
|
|
|
"https://www.xiaohongshu.com/explore/66fad51c000000001b0224b8?xsec_token=AB3rO-QopW5sgrJ41GwN01WCXh6yWPxjSoFI9D5JIMgKw=&xsec_source=pc_search"
|
2023-12-09 13:10:01 +00:00
|
|
|
|
# ........................
|
2023-11-18 05:38:11 +00:00
|
|
|
|
]
|
2023-11-18 14:07:30 +00:00
|
|
|
|
|
2024-10-19 16:59:08 +00:00
|
|
|
|
|
2023-11-26 13:43:39 +00:00
|
|
|
|
# 指定抖音需要爬取的ID列表
|
2023-11-18 14:07:30 +00:00
|
|
|
|
DY_SPECIFIED_ID_LIST = [
|
2023-12-09 13:10:01 +00:00
|
|
|
|
"7280854932641664319",
|
|
|
|
|
"7202432992642387233"
|
|
|
|
|
# ........................
|
2023-12-07 16:10:04 +00:00
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
# 指定快手平台需要爬取的ID列表
|
2024-01-14 14:06:31 +00:00
|
|
|
|
KS_SPECIFIED_ID_LIST = [
|
|
|
|
|
"3xf8enb8dbj6uig",
|
|
|
|
|
"3x6zz972bchmvqe"
|
|
|
|
|
]
|
2023-12-07 16:10:04 +00:00
|
|
|
|
|
2023-12-22 17:04:08 +00:00
|
|
|
|
# 指定B站平台需要爬取的视频bvid列表
|
2023-12-09 13:10:01 +00:00
|
|
|
|
BILI_SPECIFIED_ID_LIST = [
|
2023-12-22 17:04:08 +00:00
|
|
|
|
"BV1d54y1g7db",
|
|
|
|
|
"BV1Sz4y1U77N",
|
|
|
|
|
"BV14Q4y1n7jz",
|
2023-12-09 13:10:01 +00:00
|
|
|
|
# ........................
|
|
|
|
|
]
|
2023-12-24 16:02:11 +00:00
|
|
|
|
|
|
|
|
|
# 指定微博平台需要爬取的帖子列表
|
|
|
|
|
WEIBO_SPECIFIED_ID_LIST = [
|
|
|
|
|
"4982041758140155",
|
|
|
|
|
# ........................
|
2024-01-15 16:40:07 +00:00
|
|
|
|
]
|
2024-03-01 17:49:42 +00:00
|
|
|
|
|
2024-08-23 21:52:11 +00:00
|
|
|
|
# 指定weibo创作者ID列表
|
|
|
|
|
WEIBO_CREATOR_ID_LIST = [
|
|
|
|
|
"5533390220",
|
|
|
|
|
# ........................
|
|
|
|
|
]
|
|
|
|
|
|
2024-08-05 10:51:51 +00:00
|
|
|
|
# 指定贴吧需要爬取的帖子列表
|
|
|
|
|
TIEBA_SPECIFIED_ID_LIST = [
|
|
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
2024-08-08 06:19:32 +00:00
|
|
|
|
# 指定贴吧名称列表,爬取该贴吧下的帖子
|
|
|
|
|
TIEBA_NAME_LIST = [
|
|
|
|
|
# "盗墓笔记"
|
|
|
|
|
]
|
2024-08-05 10:51:51 +00:00
|
|
|
|
|
2024-08-24 01:12:03 +00:00
|
|
|
|
TIEBA_CREATOR_URL_LIST = [
|
2024-08-24 03:03:23 +00:00
|
|
|
|
"https://tieba.baidu.com/home/main/?id=tb.1.7f139e2e.6CyEwxu3VJruH_-QqpCi6g&fr=frs",
|
2024-08-24 01:12:03 +00:00
|
|
|
|
# ........................
|
|
|
|
|
]
|
|
|
|
|
|
2024-03-01 17:49:42 +00:00
|
|
|
|
# 指定小红书创作者ID列表
|
|
|
|
|
XHS_CREATOR_ID_LIST = [
|
2024-03-17 06:50:10 +00:00
|
|
|
|
"63e36c9a000000002703502b",
|
2024-03-01 17:49:42 +00:00
|
|
|
|
# ........................
|
2024-03-16 03:52:42 +00:00
|
|
|
|
]
|
2024-05-27 17:07:19 +00:00
|
|
|
|
|
|
|
|
|
# 指定Dy创作者ID列表(sec_id)
|
|
|
|
|
DY_CREATOR_ID_LIST = [
|
|
|
|
|
"MS4wLjABAAAATJPY7LAlaa5X-c8uNdWkvz0jUGgpw4eeXIwu_8BhvqE",
|
|
|
|
|
# ........................
|
|
|
|
|
]
|
2024-06-12 07:33:39 +00:00
|
|
|
|
|
2024-06-12 07:18:55 +00:00
|
|
|
|
# 指定bili创作者ID列表(sec_id)
|
|
|
|
|
BILI_CREATOR_ID_LIST = [
|
|
|
|
|
"20813884",
|
|
|
|
|
# ........................
|
|
|
|
|
]
|
2024-06-12 13:53:41 +00:00
|
|
|
|
|
2024-06-13 06:49:07 +00:00
|
|
|
|
# 指定快手创作者ID列表
|
|
|
|
|
KS_CREATOR_ID_LIST = [
|
|
|
|
|
"3x4sm73aye7jq7i",
|
|
|
|
|
# ........................
|
2024-06-13 06:54:01 +00:00
|
|
|
|
]
|
|
|
|
|
|
2024-10-16 13:02:27 +00:00
|
|
|
|
|
|
|
|
|
# 指定知乎创作者主页url列表
|
|
|
|
|
ZHIHU_CREATOR_URL_LIST = [
|
|
|
|
|
"https://www.zhihu.com/people/yd1234567",
|
|
|
|
|
# ........................
|
|
|
|
|
]
|
|
|
|
|
|
2024-08-08 06:19:32 +00:00
|
|
|
|
# 词云相关
|
|
|
|
|
# 是否开启生成评论词云图
|
2024-06-12 07:33:39 +00:00
|
|
|
|
ENABLE_GET_WORDCLOUD = False
|
|
|
|
|
# 自定义词语及其分组
|
2024-08-08 06:19:32 +00:00
|
|
|
|
# 添加规则:xx:yy 其中xx为自定义添加的词组,yy为将xx该词组分到的组名。
|
2024-06-12 07:33:39 +00:00
|
|
|
|
CUSTOM_WORDS = {
|
|
|
|
|
'零几': '年份', # 将“零几”识别为一个整体
|
|
|
|
|
'高频词': '专业术语' # 示例自定义词
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-08 06:19:32 +00:00
|
|
|
|
# 停用(禁用)词文件路径
|
2024-06-12 07:33:39 +00:00
|
|
|
|
STOP_WORDS_FILE = "./docs/hit_stopwords.txt"
|
|
|
|
|
|
2024-08-08 06:19:32 +00:00
|
|
|
|
# 中文字体文件路径
|
|
|
|
|
FONT_PATH = "./docs/STZHONGS.TTF"
|