python 调用googleapiclient接口采集作品详细数据

  1、代码示例

  

import googleapiclient
import googleapiclient.discovery
import googleapiclient.errors

# 测试获取账号信息
def get_account_data():
    channelId_list= ['UCj7wKsOBhRD9Jy4yahkMRMw', 'UCMeYPU1YfXjxsUa6QXWsfjg', 'UCcfLuU0NFT0ZRoQy4jk6GdA', 
                    'UCQmJk0ErE_FiorcLBsDKORA', 'UCd94YCD7yp6d-YZSRYWyeFA', 'UCA2WHG4EpVqul3TYjAF0k2A', 'UCHBDXQDmqnaqIEPdEapEFVQ', 
                    'UCK9rVTxGzOcWUR0ll18EVag', 'UCahujLjSL34EPNxtwKRi_vg', 'UC2PKbGRC3lk46Gr2Hr7QGFA', 'UCmv5DbNpxH8X2eQxJBqEjKQ', 
                    'UC-1F7DZmxTd1YZUJZUsA0nw', 'UCbPGTXpszh94pJYVfJ8lHbQ', 'UCnAsZ46UTeFEgwOEwMezngQ', 'UCEiOLQbmhmQUwRvOcYcBXtg', 
                    'UCW-oZ_79yRYG9vnwx3Pks0Q', 'UC7BxcGj6oGEMdjxR6Ld4YLw', 
                        'UCh44VuGfjHlQaBHTfoojy7A', 'UC2aWa2L_rVzIrYmmjjEEEog', 'UC2Ov25mKWtjMICagWbcBvig']
    api_service_name = "youtube"
    api_version = "v3"
    account_id_list_str = ",".join(channelId_list)
    youtube = googleapiclient.discovery.build(
        api_service_name, api_version, developerKey='AIzaSyDmNwbJ8SB2TirtaXOOXWVBNNngNnQjYwg')
    request = youtube.channels().list(
        part="id,snippet,statistics",
        id=account_id_list_str,
    )
    response = request.execute()
    return response

#测试获取视频信息
def get_video_data():
    video_id_list= ['iczEzwuBLBI', 'QImjnSoLZuE', 'w20XZRBmRMI', 'J7hTqWzMnGE', 'KqsqjbmOE_4', 'gbXyXz4IfCE',
                    '_6SeFCUAuAg', 'bhpOamVtMHc', 'doZ5Kb0UbOQ', 'eoYe3QICJHM', 'K84hn6C7D6o', 'NWQXhOJZ728',
                    'pUvj-y10TOE', 'QA3AI3HVuQo', 'qhcZzomTR2o', 'rhMQEBKE1J4', 'SgXe1qkQPhs', 'T36kB2oMvB0', 'xfGTguK2jD0', 'z67nRiyo05U']
    api_service_name = "youtube"
    api_version = "v3"
    video_id_list_str = ",".join(video_id_list)
    youtube = googleapiclient.discovery.build(
        api_service_name, api_version, developerKey='AIzaSyBjFsnV41XVnM1J8y35Lur5ji37b76TMoo')
    request = youtube.videos().list(
        part="id,snippet,statistics,contentDetails",
        id=video_id_list_str
    )
    response = request.execute()
    return response
View Code

  2、账号内存截图

      

      

    3、作品内存截图

      

·······

  4、

    https://developers.google.com/docs/api/quickstart/python?hl=zh-cn

    

      

    

        

 

        

    

 

        

    

        

        https://console.cloud.google.com/apis/library?project=nth-autumn-404702

       

        

    https://console.cloud.google.com/apis/library/youtube.googleapis.com?project=nth-autumn-404702

  

    

          

 

        

        

    

        

    

      

      

        

        

 

 

       

    YouTube Data API 概览

     https://developers.google.com/youtube/v3/getting-started?hl=zh-cn

 

 

 

 

 

 

 

 

 

 

 

      

 

posted on 2023-11-10 09:52  shaomine  阅读(118)  评论(0编辑  收藏  举报