From 3c7c678d7a90f50baf3b35fbac90de9379f3d3a6 Mon Sep 17 00:00:00 2001 From: Relakkes Date: Fri, 7 Jun 2024 13:32:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8A=96=E9=9F=B3db=E5=AD=98=E5=82=A8?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0parent=5Fcomment=5Fid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/base_config.py | 2 +- schema/tables.sql | 2 ++ store/douyin/__init__.py | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) 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')}")