diff --git a/store/weibo/__init__.py b/store/weibo/__init__.py index 3d8e590..aad007f 100644 --- a/store/weibo/__init__.py +++ b/store/weibo/__init__.py @@ -4,6 +4,7 @@ # @Desc : from typing import List +import re import config @@ -31,10 +32,12 @@ async def update_weibo_note(note_item: Dict): mblog: Dict = note_item.get("mblog") user_info: Dict = mblog.get("user") note_id = mblog.get("id") + content_text = mblog.get("text") + clean_text = re.sub(r"<.*?>", "", content_text) save_content_item = { # 微博信息 "note_id": note_id, - "content": mblog.get("text"), + "content": clean_text, "create_time": utils.rfc2822_to_timestamp(mblog.get("created_at")), "create_date_time": str(utils.rfc2822_to_china_datetime(mblog.get("created_at"))), "liked_count": str(mblog.get("attitudes_count", 0)), @@ -66,12 +69,14 @@ async def batch_update_weibo_note_comments(note_id: str, comments: List[Dict]): async def update_weibo_note_comment(note_id: str, comment_item: Dict): comment_id = str(comment_item.get("id")) user_info: Dict = comment_item.get("user") + content_text = comment_item.get("text") + clean_text = re.sub(r"<.*?>", "", content_text) save_comment_item = { "comment_id": comment_id, "create_time": utils.rfc2822_to_timestamp(comment_item.get("created_at")), "create_date_time": str(utils.rfc2822_to_china_datetime(comment_item.get("created_at"))), "note_id": note_id, - "content": comment_item.get("text"), + "content": clean_text, "sub_comment_count": str(comment_item.get("total_number", 0)), "comment_like_count": str(comment_item.get("like_count", 0)), "last_modify_ts": utils.get_current_timestamp(),