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-30 18:44:17 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2d1bae03c92e7da02287a6f6422a98aa716de622
2d1bae03
1 parent
3608a2f2
update crawling videos sorted by related
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
29 additions
and
78 deletions
client/src/chatbot/Check.js
client/src/chatbot/chatbot.js
index.js
server/routes/latest.js
server/routes/crawling.js → server/routes/news.js
server/routes/popular.js
server/routes/download.js → server/routes/related.js
client/src/chatbot/Check.js
View file @
2d1bae0
...
...
@@ -3,7 +3,7 @@ function CheckString(inputString){
var
len
=
0
;
for
(
var
i
=
0
;
i
<
inputString
.
length
;
i
++
){
if
(
inputString
[
i
]
===
'_'
){
from
=
i
;
from
=
i
+
1
;
break
;
}
}
...
...
client/src/chatbot/chatbot.js
View file @
2d1bae0
...
...
@@ -43,30 +43,21 @@ function Chatbot() {
}
try
{
if
(
inputString
[
0
]
===
'@'
){
console
.
log
(
"첫번째 i"
,
inputString
);
inputString
=
CheckString
(
inputString
);
if
(
inputString
===
'최신'
){
}
else
if
(
inputString
===
'인기'
){
}
else
if
(
inputString
===
'다운'
){
}
else
{
conversation
=
{
who
:
'소통이'
,
content
:
{
text
:
{
text
:
"잘못된 입력입니다. 다시 입력해주세요!"
}
console
.
log
(
"두번째 i"
,
inputString
);
let
response
;
if
(
inputString
===
'최신'
){
//@가수명_최신
response
=
await
Axios
.
post
(
'/api/latest/textQuery'
,
textQueryVariables
)
}
else
if
(
inputString
===
'정확도'
){
//@가수명_정확도
response
=
await
Axios
.
post
(
'/api/related/textQuery'
,
textQueryVariables
)
}
dispatch
(
saveMessage
(
conversation
)
)
else
if
(
inputString
===
'소식'
){
//@가수명_소식
response
=
await
Axios
.
post
(
'/api/news/textQuery'
,
textQueryVariables
)
}
const
response
=
await
Axios
.
post
(
'/api/crawling/textQuery'
,
textQueryVariables
)
//
const response = await Axios.post('/api/crawling/textQuery', textQueryVariables)
let
conversations
=
{}
let
pushConversations
=
[]
for
(
var
i
=
0
;
i
<
3
;
i
++
){
...
...
@@ -100,7 +91,7 @@ function Chatbot() {
who
:
'소통이'
,
content
:
{
text
:
{
text
:
"
Error just occured, please check the problem
"
text
:
"
잘못된 입력입니다. 다시 입력해주세요!
"
}
}
}
...
...
index.js
View file @
2d1bae0
...
...
@@ -8,11 +8,10 @@ const config = require("./server/config/keys");
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}));
app
.
use
(
bodyParser
.
json
());
app
.
use
(
'/api/crawling'
,
require
(
'./server/routes/crawling'
));
app
.
use
(
'/api/dialogflow'
,
require
(
'./server/routes/dialogflow'
));
app
.
use
(
'/api/latest'
,
require
(
'./server/routes/latest'
));
app
.
use
(
'/api/
popular'
,
require
(
'./server/routes/popular
'
));
app
.
use
(
'/api/
download'
,
require
(
'./server/routes/download
'
));
app
.
use
(
'/api/
related'
,
require
(
'./server/routes/related
'
));
app
.
use
(
'/api/
news'
,
require
(
'./server/routes/news
'
));
// Serve static assets if in production
if
(
process
.
env
.
NODE_ENV
===
"production"
)
{
...
...
server/routes/latest.js
View file @
2d1bae0
...
...
@@ -5,11 +5,15 @@ const uuid = require('uuid'); //uuid 제대로 이해하고 다시 작성하기.
const
axios
=
require
(
'axios'
);
const
cheerio
=
require
(
'cheerio'
);
//@가수명 으로 입력이 들어왔을 때, 가수명만 받아서
//@가수명
_최신
으로 입력이 들어왔을 때, 가수명만 받아서
router
.
post
(
'/textQuery'
,
async
(
req
,
res
)
=>
{
const
result
=
req
.
body
.
text
;
var
name
=
result
.
substring
(
1
)
var
i
=
0
;
for
(
i
;
i
<
result
.
length
;
i
++
){
if
(
result
[
i
]
===
'_'
)
break
;
}
var
name
=
result
.
substr
(
1
,
i
-
1
);
var
url
=
'https://tv.naver.com/search/clip?query='
//naverTV의 링크
var
sort
=
'&sort=date'
...
...
server/routes/
crawling
.js
→
server/routes/
news
.js
View file @
2d1bae0
File moved
server/routes/popular.js
deleted
100644 → 0
View file @
3608a2f
const
express
=
require
(
'express'
);
const
router
=
express
.
Router
();
const
uuid
=
require
(
'uuid'
);
//uuid 제대로 이해하고 다시 작성하기.
const
axios
=
require
(
'axios'
);
const
cheerio
=
require
(
'cheerio'
);
//@가수명 으로 입력이 들어왔을 때, 가수명만 받아서
router
.
post
(
'/textQuery'
,
async
(
req
,
res
)
=>
{
const
result
=
req
.
body
.
text
;
var
name
=
result
.
substring
(
1
)
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'
)
}
})
data
=
videoList
.
filter
(
n
=>
n
.
title
);
data
=
JSON
.
stringify
(
data
.
slice
(
0
,
3
))
res
.
send
(
data
);
})
})
module
.
exports
=
router
;
\ No newline at end of file
server/routes/
downloa
d.js
→
server/routes/
relate
d.js
View file @
2d1bae0
...
...
@@ -5,14 +5,20 @@ const uuid = require('uuid'); //uuid 제대로 이해하고 다시 작성하기.
const
axios
=
require
(
'axios'
);
const
cheerio
=
require
(
'cheerio'
);
//@가수명 으로 입력이 들어왔을 때, 가수명만 받아서
//@가수명
_정확도
으로 입력이 들어왔을 때, 가수명만 받아서
router
.
post
(
'/textQuery'
,
async
(
req
,
res
)
=>
{
const
result
=
req
.
body
.
text
;
var
name
=
result
.
substring
(
1
)
//가수명 추출
var
i
=
0
;
for
(
i
;
i
<
result
.
length
;
i
++
){
if
(
result
[
i
]
===
'_'
)
break
;
}
var
name
=
result
.
substr
(
1
,
i
-
1
);
var
url
=
'https://tv.naver.com/search/clip?query='
//naverTV의 링크
var
sort
=
'&sort=
date
'
var
sort
=
'&sort=
rel
'
url
=
url
+
name
+
sort
url
=
encodeURI
(
url
)
console
.
log
(
"url is "
,
url
)
...
...
Please
register
or
login
to post a comment