test.js
1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//https://www.npmjs.com/package/youtube-v3-api
//http://khuhub.khu.ac.kr/2019102147/youtube-comment-seperator.git
const apiKey = 'AIzaSyCjBrFKnBlGvxsfOD-qJP8nBkdEoqKRHu8';
const {google} = require("googleapis");
const service = google.youtube('v3');
service.commentThreads.list({
"key":apiKey,
"part":[
"snippet, replies"
],
"videoId":"m1gHR4dJhKU"//비디오 주소
}).then(function(response) {
console.log("Response", response);
console.log(response.data.items[0].snippet.topLevelComment.snippet.textDisplay)
console.log(response.data.items[1].snippet.topLevelComment.snippet.textDisplay)
},
function(err) { console.error("Execute error", err); });
/*
service.comments.list({
"key": apiKey,
"part": [
"snippet"
],
"parentId": "UgzDE2tasfmrYLyNkGt4AaABAg"
}).then(function(response) {
// Handle the results here (response.result has the parsed body).
console.log("Response", response);
console.log(response.data.items)
},
function(err) { console.error("Execute error", err); });
const {YoutubeDataAPI} = require("youtube-v3-api");
const {google} = require("googleapis");
const api = new YoutubeDataAPI(apiKey);
api.searchComments("https://youtu.be/m1gHR4dJhKU").then((data)=>{
console.log(data);
console.log(data.pageInfo);
},(err)=>{
console.error(err);
})
*/