开发者社区

作者:佚名 时间:2025-11-18 16:14

字号

本文将详细介绍如何通过官方API接口获取快手平台视频评论数据,并提供Python实现示例。

一、接口基本信息

二、请求参数说明

参数名 类型 是否必选 说明

video_id string 是 目标视频的唯一标识

cursor int 否 分页游标(初始值为0)

count int 否 每页数量(默认20,最大100)

三、返回数据结构

"code": 200,

"message": "success",

"data": {

"comments":

"comment_id": "C_123456",

"user_id": "U_789012",

"content": "这个视频太棒了!",

"create_time": 1689235200,

"like_count": 128

"cursor": 100,

"has_more": true

四、Python调用示例

import requests

import json

def get_kuaishou_comments(video_id, access_token):

url = "https://open.kuaishou.com/api/v1/comment/list"

headers = {"Authorization": f"Bearer {access_token}"}

params = {

"video_id": video_id,

"cursor": 0,

"count": 50

try:
    response = requests.get(url, headers=headers, params=params)
    if response.status_code == 200:
        data = response.json()
        if data['code'] == 200:
            return data['data']['comments']
        else:
            print(f"API错误: {data['message']}")
    else:
        print(f"HTTP错误: {response.status_code}")
except Exception as e:
    print(f"请求异常: {str(e)}")
return []

示例调用

access_token = "your_access_token_here"

video_id = "VIDEO123456"

comments = get_kuaishou_comments(video_id, access_token)

for comment in comments:

print(f"用户{comment

'user_id'

责任编辑:CQITer新闻报料:400-888-8888   本站原创,未经授权不得转载
继续阅读
热新闻
推荐
关于我们联系我们免责声明隐私政策 友情链接