我正在尝试通过YouTube API收集特定类别中最受欢迎的视频的记录。出于某种原因,指定类别时无法获得任何结果,但是使用相同的代码可以获得未指定类别的结果。有什么明显的地方我做错了吗?
import requests
import json
developerKey = "DEVELOPER KEY"
category = "26"
r = requests.get("https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails,statistics&chart=mostPopular&videoCategoryId="+category+"&key="+developerKey)
json_data = r.json()
nextPageToken = json_data.get("nextPageToken")
while nextPageToken:
r = requests.get("https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails,statistics&chart=mostPopular&videoCategoryId="+category+"&key="+developerKey+"&pageToken="+nextPageToken)
json_data = r.json()
nextPageToken = json_data.get("nextPageToken")
print(r.text)