Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
search-page
Commits
2813e438
Commit
2813e438
authored
Jan 21, 2021
by
Kim, Chaerin
Browse files
ㅠ
parent
517cbcbb
Changes
1
Hide whitespace changes
Inline
Side-by-side
server/controllers/review.controller.js
View file @
2813e438
import
Review
from
'
../models/Review.js
'
import
cheerio
,
{
html
}
from
"
cheerio
"
;
import
jschardet
from
'
jschardet
'
import
iconv
from
'
iconv
'
import
fs
from
'
fs
'
import
axios
from
'
axios
'
;
import
{
nextTick
}
from
'
process
'
;
const
Iconv
=
iconv
.
Iconv
const
search
=
async
(
req
,
res
,
next
)
=>
{
try
{
let
reviews
=
[]
let
content
=
[]
Review
.
find
()
const
url
=
"
https://www.google.com/search?q=
"
+
encodeURI
(
req
.
params
.
search
)
+
"
+site%3Atistory.com&page_no=1
"
const
response1
=
await
axios
.
get
(
url
)
// console.log(response1.data)
...
...
@@ -32,7 +31,9 @@ const search = async (req, res, next) => {
promiseReview
=
promiseReview
.
filter
(
e
=>
typeof
(
e
)
===
'
string
'
)
reviews
.
forEach
(
async
(
review
,
i
)
=>
{
review
[
"
content
"
]
=
promiseReview
[
i
]
const
reviews
=
new
Review
(
review
).
save
()
})
res
.
send
(
reviews
)
}
catch
(
error
)
{
console
.
log
(
error
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment