Get title from YouTube videos

前端 未结 17 1925
抹茶落季
抹茶落季 2020-12-07 17:30

I want to extract the Title of YouTube\'s videos. How can I do this?

Thanks.

17条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-07 17:50

    I believe the best way is to use youTube's gdata, and then grab info from XML that is returned

    http://gdata.youtube.com/feeds/api/videos/6_Ukfpsb8RI

    Update: There is a newer API out now which you should use instead

    https://developers.google.com/youtube/v3/getting-started

    URL: https://www.googleapis.com/youtube/v3/videos?id=7lCDEYXw3mM&key=YOUR_API_KEY
         &fields=items(id,snippet(channelId,title,categoryId),statistics)&part=snippet,statistics
    
    Description: This example modifies the fields parameter from example 3 so that in the API response, each video resource's snippet object only includes the channelId, title, and categoryId properties.
    
    API response:
    
    {
     "videos": [
      {
       "id": "7lCDEYXw3mM",
       "snippet": {
        "channelId": "UC_x5XG1OV2P6uZZ5FSM9Ttw",
        "title": "Google I/O 101: Q&A On Using Google APIs",
        "categoryId": "28"
       },
       "statistics": {
        "viewCount": "3057",
        "likeCount": "25",
        "dislikeCount": "0",
        "favoriteCount": "17",
        "commentCount": "12"
       }
      }
     ]
    }
    

提交回复
热议问题