diff --git a/config/base_config.py b/config/base_config.py index 3a8918f..ee55a87 100644 --- a/config/base_config.py +++ b/config/base_config.py @@ -47,7 +47,7 @@ ENABLE_GET_COMMENTS = False # 是否开启爬二级评论模式, 默认不开启爬二级评论, 目前仅支持 xhs # 老版本项目使用了 db, 则需参考 schema/tables.sql line 287 增加表字段 -ENABLE_GET_SUB_COMMENTS = False +ENABLE_GET_SUB_COMMENTS = True # 指定小红书需要爬虫的笔记ID列表 XHS_SPECIFIED_ID_LIST = [ diff --git a/schema/tables.sql b/schema/tables.sql index 3fbda14..fa475e1 100644 --- a/schema/tables.sql +++ b/schema/tables.sql @@ -308,5 +308,7 @@ CREATE TABLE `xhs_note_comment` ( ALTER TABLE `xhs_note_comment` ADD COLUMN `parent_comment_id` VARCHAR(64) DEFAULT NULL COMMENT '父评论ID'; +ALTER TABLE `douyin_aweme_comment` +ADD COLUMN `parent_comment_id` VARCHAR(64) DEFAULT NULL COMMENT '父评论ID'; SET FOREIGN_KEY_CHECKS = 1; diff --git a/store/douyin/__init__.py b/store/douyin/__init__.py index 73acd36..6b8a753 100644 --- a/store/douyin/__init__.py +++ b/store/douyin/__init__.py @@ -70,6 +70,7 @@ async def update_dy_aweme_comment(aweme_id: str, comment_item: Dict): return user_info = comment_item.get("user", {}) comment_id = comment_item.get("cid") + parent_comment_id = comment_item.get("reply_id", "0") avatar_info = user_info.get("avatar_medium", {}) or user_info.get("avatar_300x300", {}) or user_info.get( "avatar_168x168", {}) or user_info.get("avatar_thumb", {}) or {} save_comment_item = { @@ -87,6 +88,7 @@ async def update_dy_aweme_comment(aweme_id: str, comment_item: Dict): "avatar": avatar_info.get("url_list", [""])[0], "sub_comment_count": str(comment_item.get("reply_comment_total", 0)), "last_modify_ts": utils.get_current_timestamp(), + "parent_comment_id": parent_comment_id } utils.logger.info( f"[store.douyin.update_dy_aweme_comment] douyin aweme comment: {comment_id}, content: {save_comment_item.get('content')}")