Skip to content

Commit

Permalink
fix(小红书-动态): 跳过不符合规范的数据 #16
Browse files Browse the repository at this point in the history
  • Loading branch information
nfe-w committed May 22, 2024
1 parent 155ea4e commit 574b6d7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions query_task/query_xhs.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ def query_dynamic(self, profile_id=None):
super().handle_for_result_null("-1", profile_id, "小红书", user_name)
return

# 循环遍历 notes ,剔除不满足要求的数据
notes = [note for note in notes if
note.get("noteCard") is not None # 跳过不包含 noteCard 的数据
and (note["noteCard"].get("interactInfo") is None or note["noteCard"]["interactInfo"].get("sticky") is not True) # 跳过置顶
]

# 跳过置顶后再判断一下,防止越界
if len(notes) == 0:
super().handle_for_result_null("-1", profile_id, "小红书", user_name)
return

note = notes[0]
note_id = note["id"]

Expand Down

0 comments on commit 574b6d7

Please sign in to comment.