add 'commit' function
This commit is contained in:
parent
2e884c6ab7
commit
68847dc54f
2 changed files with 16 additions and 1 deletions
|
@ -341,6 +341,16 @@ class XiaoHongShuClient(AbstractApiClient):
|
|||
explore_id.append(id)
|
||||
return explore_id
|
||||
|
||||
async def commit_note(self, note_oid: str, content: str, at_users: list) -> Dict:
|
||||
uri = "/api/sns/web/v1/comment/post"
|
||||
data = {
|
||||
"note_id": note_oid,
|
||||
"content": content,
|
||||
"at_users": at_users
|
||||
}
|
||||
#at_users: {"user_id":"6157c0f1000000000201d0d2","nickname":"小红薯6158C511"}
|
||||
return await self.post(uri, data)
|
||||
|
||||
async def like_note(self, note_oid: str) -> Dict:
|
||||
uri = "/api/sns/web/v1/note/like"
|
||||
data = {
|
||||
|
|
|
@ -84,7 +84,7 @@ class XiaoHongShuCrawler(AbstractCrawler):
|
|||
elif config.CRAWLER_TYPE == "explore":
|
||||
await self.get_explore()
|
||||
elif config.CRAWLER_TYPE == "test":
|
||||
await self.like()
|
||||
await self.commit()
|
||||
else:
|
||||
pass
|
||||
|
||||
|
@ -132,6 +132,11 @@ class XiaoHongShuCrawler(AbstractCrawler):
|
|||
except DataFetchError:
|
||||
utils.logger.error("[XiaoHongShuCrawler.search] Get note detail error")
|
||||
break
|
||||
async def commit(self) -> None:
|
||||
note_id = "66430c5f000000001e01ed41"
|
||||
ret_v = await self.xhs_client.commit_note(note_id, "你好👋", [])
|
||||
print(ret_v)
|
||||
|
||||
async def like(self) -> None:
|
||||
note_oid = "65f54b1c0000000012022342"
|
||||
ret_v = await self.xhs_client.like_note(note_oid)
|
||||
|
|
Loading…
Reference in a new issue