Toggle navigation
Toggle navigation
This project
Loading...
Sign in
이승윤
/
OpenSource-MyCookBook
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Song
2021-05-22 21:04:41 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7e32721fda52c8a02d83890a750a6dfe959fe01f
7e32721f
1 parent
710bf081
검색기능
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
Search.js
Search.js
0 → 100644
View file @
7e32721
var
Youtube
=
require
(
'youtube-node'
);
var
youtube
=
new
Youtube
();
var
word
=
'백종원 레시피'
;
// 검색어 지정
var
limit
=
10
;
// 출력 갯수
youtube
.
setKey
(
'AIzaSyAsKr_oWGZIBbL5tLdIl98Lf9Pzqj8jX4o'
);
// API 키 입력
youtube
.
addParam
(
'order'
,
'rating'
);
// 평점 순으로 정렬
youtube
.
addParam
(
'type'
,
'video'
);
// 타입 지정
youtube
.
addParam
(
'videoLicense'
,
'creativeCommon'
);
// 크리에이티브 커먼즈 아이템만 불러옴
youtube
.
search
(
word
,
limit
,
function
(
err
,
result
)
{
// 검색 실행
if
(
err
)
{
console
.
log
(
err
);
return
;
}
// 에러일 경우 에러공지하고 빠져나감
console
.
log
(
JSON
.
stringify
(
result
,
null
,
2
));
// 받아온 전체 리스트 출력
var
items
=
result
[
"items"
];
// 결과 중 items 항목만 가져옴
for
(
var
i
in
items
)
{
var
it
=
items
[
i
];
var
title
=
it
[
"snippet"
][
"title"
];
var
video_id
=
it
[
"id"
][
"videoId"
];
var
url
=
"https://www.youtube.com/watch?v="
+
video_id
;
console
.
log
(
"제목 : "
+
title
);
console
.
log
(
"URL : "
+
url
);
console
.
log
(
"-----------"
);
}
});
\ No newline at end of file
Please
register
or
login
to post a comment