youtube-api - 在 YouTube 上获取热门新闻视频的 ID 时遇到问题?
问题描述
我一直在尝试使用 YouTube 数据 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)
解决方案
试试这个,看看你是怎么做的。
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
一切顺利。
推荐阅读
- r - 如何从一元组中删除(自定义)停用词但将它们保留在二元组中?
- typescript - 如何正确地将 VScode 的语言服务器扩展与内部的客户端和服务器捆绑在一起
- python - 抓取网站时获取多个类的内容
- javascript - 带有动态选项卡项的 Nativescript 选项卡视图
- vb.net - VB.NET 中的登录表单不允许用户在输入正确的登录详细信息之前错误地输入登录详细信息后登录
- python - 从随机字符串中过滤单词(Python)
- c# - 无法在此范围内声明,因为该名称在封闭的本地范围内使用
- webpack - 在 npm run dev 期间收到 webpack 警告并在 Next.js 中首次加载
- sql - SQL Server:执行计划解释
- sql - SQL - SFW,在哪里使用 IN