使用 Youtube 数据的响应负载不正确 API
Response Payload incorrect using Youtube Data API
我正在尝试使用 Youtube 的数据 API 来获取有关各种频道的一些信息,但是当我 运行 我的构建时:
youtube = build('youtube', 'v3',developerKey=api_key)
request = youtube.channels().list(
part = "statistics",
forUsername = "tonetalks"
)
response = request.execute()
print(response)
它returns这个:
{'kind': 'youtube#channelListResponse', 'etag': 'RuuXzTIr0OoDqI4S0RU6n4FqKEM', 'pageInfo': {'totalResults': 0, 'resultsPerPage': 5}}
有什么办法解决这个问题吗?
forUsername
不正确。如果您要查找 this "tonetalks" channel,则必须使用其 ID UCfP8rCe_fAITriqI3UPYF0Q
(来自上述频道 URL):
request = youtube.channels().list(
part = "statistics",
id = "UCfP8rCe_fAITriqI3UPYF0Q",
)
{
"kind": "youtube#channelListResponse",
"etag": "5gs56_i4Xd_fQ4A1OkQEnWWnX7A",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#channel",
"etag": "m7gogJwH4TshrBX4PCiuFP5MsJI",
"id": "UCfP8rCe_fAITriqI3UPYF0Q",
"statistics": {
"viewCount": "6033544",
"subscriberCount": "81200",
"hiddenSubscriberCount": false,
"videoCount": "229"
}
}
]
}
我正在尝试使用 Youtube 的数据 API 来获取有关各种频道的一些信息,但是当我 运行 我的构建时:
youtube = build('youtube', 'v3',developerKey=api_key)
request = youtube.channels().list(
part = "statistics",
forUsername = "tonetalks"
)
response = request.execute()
print(response)
它returns这个:
{'kind': 'youtube#channelListResponse', 'etag': 'RuuXzTIr0OoDqI4S0RU6n4FqKEM', 'pageInfo': {'totalResults': 0, 'resultsPerPage': 5}}
有什么办法解决这个问题吗?
forUsername
不正确。如果您要查找 this "tonetalks" channel,则必须使用其 ID UCfP8rCe_fAITriqI3UPYF0Q
(来自上述频道 URL):
request = youtube.channels().list(
part = "statistics",
id = "UCfP8rCe_fAITriqI3UPYF0Q",
)
{
"kind": "youtube#channelListResponse",
"etag": "5gs56_i4Xd_fQ4A1OkQEnWWnX7A",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#channel",
"etag": "m7gogJwH4TshrBX4PCiuFP5MsJI",
"id": "UCfP8rCe_fAITriqI3UPYF0Q",
"statistics": {
"viewCount": "6033544",
"subscriberCount": "81200",
"hiddenSubscriberCount": false,
"videoCount": "229"
}
}
]
}