How to get all comments on a YouTube video?

2019-01-21 14:18发布

Since Google has deprecated the YouTube v2 API, I cannot find a way to get all the comments from a video.

Is it possible to use a single, non-deprecated API (Google+, YT v3) to do that?

I am not concerned about maintaining threading.

4条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-01-21 14:32

Apparently it is now possible to fetch comment threads.


(old answer)

Currently that's impossible with a first-party tool.

Source:

While v3 offers the majority of v2 functionality, there are currently a couple of tasks that can only be done with the older API. Specifically, applications that manage captions or that work with video comments still need to use the v2 API until modern equivalents are available. Our goal is to provide similar functionality well before the April 2015 shut-off date—please subscribe to this blog, the YouTube Data API v3 revision history page, or follow +YouTubeDev on Google+ to keep up-to-date. - http://apiblog.youtube.com/2014/03/committing-to-youtube-data-api-v3.html

TubeKit (YouTube crawling toolkit) might be of help to some.

查看更多
对你真心纯属浪费
3楼-- · 2019-01-21 14:38
$.ajax({
        dataType: "jsonp",
        type: 'GET',
url: "https://www.googleapis.com/youtube/v3/commentThreads?key=PUT-YOUR-KEYXXXXXXX&textFormat=plainText&part=snippet&videoId=PUT-YOUR-VIDEO-ID",
        success: function(result){
            data = result;
            $('.data').text(data);
            console.log(data);
    }});

To find PUT-YOUR-KEY(API key) ---> https://console.developers.google.com/apis/credentials then click on blue color button select API key option you can get

查看更多
成全新的幸福
4楼-- · 2019-01-21 14:39

You can get only 100 at most at a time with the comments API. But you get a nextPageToken from the response. Pass pageToken={nextPageToken} to next call, until the nextPageToken is undefined. Then you can get all comments if you like.

https://www.googleapis.com/youtube/v3/commentThreads?key={your_api_key}&textFormat=plainText&part=snippet&videoId={video_id}&maxResults=100&pageToken={nextPageToken}
查看更多
Lonely孤独者°
5楼-- · 2019-01-21 14:49

Believe me it works and I am 100 % sure

https://www.googleapis.com/youtube/v3/commentThreads?key=******************&textFormat=plainText&part=snippet&videoId=kffacxfA7G4&maxResults=50

Key will be provided by the google developer console and 50 denotes 50 comments in form of a json. for any type of queries comment below and video id id of the video

查看更多
登录 后发表回答