【问题标题】:How to see the subscribers count of a youtube channel using the gdata api in python如何在 python 中使用 gdata api 查看 youtube 频道的订阅者数量
【发布时间】:2016-12-27 20:09:33
【问题描述】:

我试图制作一个树莓派 youtube 子监视器,但我对如何从 python 中的 youtube 频道获取子数感到困惑。非常感谢这样做的示例代码。

【问题讨论】:

    标签: python google-api youtube-api youtube-data-api gdata


    【解决方案1】:

    请先熟悉basic YouTube Data API v3 workflows

    有多种方法可以将 API 与 Python 结合使用。由于您的应用程序似乎不是很复杂,您可以使用 Python 的 HTTP 库之一(取决于您的 Python 版本)directly perform a request to the API

    或者,您可以使用Python client library (examples)。

    无论如何,您都需要注册一个应用程序和obtain an API key in the Google Cloud Console

    【讨论】:

      【解决方案2】:

      使用此 URI 请求在 PYTHON 中进行 REST 调用:

      GET https://www.googleapis.com/youtube/v3/subscriptions?part=snippet&mySubscribers=true&fields=pageInfo&key={YOUR_API_KEY}
      

      totalResults 键保存订阅者的数量。我得到的响应示例如下所示:

      {
      "pageInfo": {
      "totalResults": 2,
      "resultsPerPage": 5
        }
      }
      

      在这种情况下,它是 2 个订阅者。

      我建议你学习Python Quickstarts 代码结构并学习如何进行 REST 调用。

      查看Subscriptions: list 了解更多信息,尤其是试用版部分,以便您立即看到结果。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-10-03
        • 2015-09-27
        • 1970-01-01
        • 2015-03-27
        • 1970-01-01
        • 2021-02-19
        • 2018-04-21
        • 2015-08-23
        相关资源
        最近更新 更多