Toggle navigation
Toggle navigation
This project
Loading...
Sign in
서민정
/
SEARCH-AND-CHAT
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
2
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
서민정
2020-05-19 16:20:22 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
eb523c4feba24a887901dba0eb772f7bc9ab50c7
eb523c4f
1 parent
72bdb346
update chatbot
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1 additions
and
60 deletions
client/src/chatbot/chatbot.js
server/cheerio/video.js
server/routes/crawling.js
client/src/chatbot/chatbot.js
View file @
eb523c4
...
...
@@ -43,12 +43,9 @@ function Chatbot() {
const
response
=
await
Axios
.
post
(
'/api/crawling/textQuery'
,
textQueryVariables
)
console
.
log
(
"res"
,
response
)
for
(
let
content
of
response
.
data
)
{
for
(
let
content
of
response
.
data
)
{
console
.
log
(
content
)
}
}
else
{
//I will send request to the textQuery ROUTE
...
...
@@ -161,10 +158,6 @@ function Chatbot() {
}
// template for card message
...
...
server/cheerio/video.js
deleted
100644 → 0
View file @
72bdb34
const
axios
=
require
(
'axios'
);
const
cheerio
=
require
(
'cheerio'
);
/*
이런 식으로 전달해야함. card 컴포넌트에
{
"description": "Youtube",
"image": "",
"link": "https://www.youtube.com",
"stack": "minjeong"
}
*/
module
.
exports
=
function
video
(
name
){
console
.
log
(
"My favorite singer"
,
name
)
var
url
=
'https://tv.naver.com/search/clip?query='
//naverTV의 링크
var
sort
=
'&sort=date'
url
=
url
+
name
+
sort
url
=
encodeURI
(
url
)
console
.
log
(
"url is "
,
url
)
const
getHtml
=
async
()
=>
{
try
{
return
await
axios
.
get
(
url
);
//axios.get 함수를 이용해서 비동기로 네이버티비의 해당 가수의 최신 영상 html 파일을 가져온다.
}
catch
(
error
){
console
.
log
(
"error! check your code"
);
}
};
getHtml
()
.
then
(
html
=>
{
let
videoList
=
[];
const
$
=
cheerio
.
load
(
html
.
data
);
const
$bodyList
=
$
(
"div.src_wrap div.thl "
).
children
(
"div.thl_a"
);
$bodyList
.
each
(
function
(
i
,
elem
){
videoList
[
i
]
=
{
description
:
"naverTV"
,
image
:
$
(
this
).
find
(
'a.cds_thm'
).
children
(
'img'
).
attr
(
'src'
),
title
:
$
(
this
).
find
(
'a.cds_thm'
).
attr
(
'title'
),
link
:
"https://tv.naver.com/"
+
$
(
this
).
find
(
'a.cds_thm'
).
attr
(
'href'
)
}
})
var
data
=
videoList
.
filter
(
n
=>
n
.
title
);
data
=
JSON
.
stringify
(
data
.
slice
(
0
,
3
))
return
data
;
})
//.then(res=>console.log(res));
}
server/routes/crawling.js
View file @
eb523c4
const
express
=
require
(
'express'
);
const
router
=
express
.
Router
();
const
uuid
=
require
(
'uuid'
);
//uuid 제대로 이해하고 다시 작성하기.
//const video = require('../cheerio/video');
const
axios
=
require
(
'axios'
);
const
cheerio
=
require
(
'cheerio'
);
...
...
Please
register
or
login
to post a comment