diff --git a/docs/api/xhs/xhs.md b/docs/api/xhs/xhs.md index 8a40a04..0af79d5 100644 --- a/docs/api/xhs/xhs.md +++ b/docs/api/xhs/xhs.md @@ -131,7 +131,6 @@ |:---:|:---:|:---:|:---:| | id | true | string | 小红书笔记id,从网页链接中获取,例如: 6653f0820000000005005f9b | | comment_id | true | string | 笔记评论id,从评论中获得到的id,例如: 6654b9ac000000001c015031 | -| cursor | true | string | 笔记评论游标id,从评论中获得到的sub_comment_cursor,例如: 66551bdb000000001c0248d1 | | offset | false | int | 评论翻页偏移量, 默认0 | | limit | false | int | 评论数量, 默认20 | diff --git a/service/xhs/logic/replys.py b/service/xhs/logic/replys.py index 021ae33..8916468 100644 --- a/service/xhs/logic/replys.py +++ b/service/xhs/logic/replys.py @@ -1,5 +1,5 @@ from .common import common_request -def request_replys(id: str, comment_id: str, cursor: str, cookie: str, offset: int = 0, limit: int = 20) -> tuple[dict, bool]: +def request_replys(id: str, comment_id: str, cookie: str, offset: int = 0, limit: int = 20) -> tuple[dict, bool]: """ 请求小红书获取评论回复信息 """ @@ -7,6 +7,7 @@ def request_replys(id: str, comment_id: str, cursor: str, cookie: str, offset: i end_length = offset + limit comments = [] has_more = True + cursor = '' while has_more and len(comments) < end_length: data = { "note_id": id, diff --git a/service/xhs/views/replys.py b/service/xhs/views/replys.py index 6cda3f6..76d524e 100644 --- a/service/xhs/views/replys.py +++ b/service/xhs/views/replys.py @@ -12,7 +12,6 @@ def replys(): """ id = request.args.get('id', '') comment_id = request.args.get('comment_id', '') - cursor = request.args.get('cursor', '') offset = int(request.args.get('offset', 0)) limit = int(request.args.get('limit', 10)) _accounts = accounts.load() @@ -20,12 +19,12 @@ def replys(): for account in _accounts: if account.get('expired', 0) == 1: continue - res, succ = request_replys(id, comment_id, cursor, account.get('cookie', ''), offset, limit) + res, succ = request_replys(id, comment_id, account.get('cookie', ''), offset, limit) if not succ: accounts.expire(account.get('id', '')) if res == {} or not succ: continue - logger.info(f'get reply success, id: {id}, comment_id: {comment_id}, cursor: {cursor}, offset: {offset}, limit: {limit}, res: {res}') + logger.info(f'get reply success, id: {id}, comment_id: {comment_id}, offset: {offset}, limit: {limit}, res: {res}') return reply(ErrorCode.OK, '成功' , res) - logger.warning(f'get reply failed, id: {id}, comment_id: {comment_id}, cursor: {cursor}, offset: {offset}, limit: {limit}') + logger.warning(f'get reply failed, id: {id}, comment_id: {comment_id}, offset: {offset}, limit: {limit}') return reply(ErrorCode.INTERNAL_ERROR, '内部错误请重试') \ No newline at end of file