fix: 修复小红书笔记获取时,不存在的笔记异常问题

This commit is contained in:
Relakkes 2023-12-04 21:54:12 +08:00
parent 519165ceec
commit a790d72db9
1 changed files with 4 additions and 2 deletions

View File

@ -133,8 +133,10 @@ class XHSClient:
data = {"source_note_id": note_id}
uri = "/api/sns/web/v1/feed"
res = await self.post(uri, data)
res_dict: Dict = res["items"][0]["note_card"]
return res_dict
if res and res.get("items"):
res_dict: Dict = res["items"][0]["note_card"]
return res_dict
return dict()
async def get_note_comments(self, note_id: str, cursor: str = "") -> Dict:
"""get note comments