LoginSignup
10
6

More than 3 years have passed since last update.

Youtubeのチャンネル登録者数を取得する

Last updated at Posted at 2020-03-23

Youtube Data APIを用いたバーチャルYoutuberのデータ収集 - Qiita の写経

Channels  |  YouTube Data API  |  Google Developers

nijisanji.py
from googleapiclient.discovery import build

YOUTUBE_API_KEY = '<API KEY>'


def youtube_channel_detail(channel_id, api_key):
    api_service_name = 'youtube'
    api_version = 'v3'
    youtube = build(api_service_name, api_version, developerKey=api_key)
    search_response = youtube.channels().list(
        part='snippet,statistics',
        id=channel_id,
    ).execute()

    return search_response['items'][0]


def main():

    d = youtube_channel_detail('UCHVXbQzkl3rDfsXWo8xi2qw', YOUTUBE_API_KEY)
    print(d['snippet']['title'])
    print(d['statistics']['subscriberCount'])
$ python3 nijisannji.py
アンジュ・カトリーナ - Ange Katrina -
257000
10
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
6