快手(中国)
快手视频评论 API
获取快手(中国)视频下的评论:评论内容、作者昵称和 id、IP 属地省份、点赞数、回复数和时间,每页 30 条一级评论,以 JSON 返回。每页消耗 1 积分,抓取完整评论区成本很低。采用游标分页:把响应中的 pcursor 作为 cursor 传回即可。热门评论的前几条回复会随同一个响应免费附带。
POST/api/v1/kuaishou/video/comments
Authorizations
AuthorizationstringheaderrequiredBearer authentication header of the form Bearer <token>, where <token> is your Scavio API key (e.g. Bearer sk_live_your_key).
Body
application/jsonphoto_idstringrequired快手 photo(视频)id,不能为空。字母数字形式(3x7gxp2zhgjv832)和数字形式都可以。本接口只接受 id,不接受链接;如果手上只有链接,请先用视频详情接口解析。
Example: 3x7gxp2zhgjv832
cursorstring不透明的分页游标(cursor)。第一页不传,之后传入上一次响应中的 pcursor 值。响应字段名是 pcursor,不是 next_cursor。pcursor 为 "no_more" 表示没有更多页。
Example: V2#ac1b6760-96d6-4d3a-93b2-21c30e0953db#dph#30#846697657492_30
Request
from scavio import ScavioClient
client = ScavioClient(api_key="sk_live_your_key")
cursor = None
while True:
page = client.kuaishou.video_comments(photo_id="3x7gxp2zhgjv832", cursor=cursor)
for c in page["data"].get("rootComments", []):
print(c["author_name"], c["authorArea"], c["likedCount"], c["content"])
cursor = page["data"].get("pcursor") # 不是 next_cursor
if not cursor or cursor == "no_more":
breakResponse
"result": 1,
"commentCount": 104944,
"pcursor": "V2#ac1b6760-96d6-4d3a-93b2-21c30e0953db#dph#30#846697657492_30"
},
"response_time": 1464,
"credits_used": 1,
"credits_remaining": 4814
}