我一直在尝试使用YouTube Data API从美国获取热门新闻视频。但是,虽然我没有收到错误,但我没有收到任何结果。我发现很难相信没有结果,因为YouTube的热门新闻页面显示了许多视频。
我得到的回报是:
{'kind': 'youtube#videoListResponse', 'etag': 'KtFSnIG_fmDzS9uX1a7JuXFZJbk', 'items': [], 'pageInfo': {'totalResults': 0, 'resultsPerPage': 5}}我的代码:
youtube = build("youtube","v3", developerKey=apiKey)
request = youtube.videos().list(
part = "id",
chart = "mostPopular",
regionCode = "US",
videoCategoryId = "25"
)
response = request.execute()
print(response)发布于 2021-02-01 01:13:43
试试这个,看看你是怎么做的。
result = self.youtube.search().list(
part="snippet",
regionCode="US",
videoCategoryId = 25,
order="viewCount",
type="video",
).execute()
for item in result['items']:
print()
print(item["id"]["videoId"])
return result万事如意。
https://stackoverflow.com/questions/65961238
复制相似问题