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
Show whitespace changes
Inline
Side-by-side
server/controllers/review.controller.js
View file @
2813e438
import
Review
from
'
../models/Review.js
'
import
Review
from
'
../models/Review.js
'
import
cheerio
,
{
html
}
from
"
cheerio
"
;
import
cheerio
,
{
html
}
from
"
cheerio
"
;
import
jschardet
from
'
jschardet
'
import
iconv
from
'
iconv
'
import
iconv
from
'
iconv
'
import
fs
from
'
fs
'
import
fs
from
'
fs
'
import
axios
from
'
axios
'
;
import
axios
from
'
axios
'
;
import
{
nextTick
}
from
'
process
'
;
const
Iconv
=
iconv
.
Iconv
const
Iconv
=
iconv
.
Iconv
const
search
=
async
(
req
,
res
,
next
)
=>
{
const
search
=
async
(
req
,
res
,
next
)
=>
{
try
{
try
{
let
reviews
=
[]
let
reviews
=
[]
let
content
=
[]
let
content
=
[]
Review
.
find
()
const
url
=
"
https://www.google.com/search?q=
"
+
encodeURI
(
req
.
params
.
search
)
+
"
+site%3Atistory.com&page_no=1
"
const
url
=
"
https://www.google.com/search?q=
"
+
encodeURI
(
req
.
params
.
search
)
+
"
+site%3Atistory.com&page_no=1
"
const
response1
=
await
axios
.
get
(
url
)
const
response1
=
await
axios
.
get
(
url
)
// console.log(response1.data)
// console.log(response1.data)
...
@@ -32,7 +31,9 @@ const search = async (req, res, next) => {
...
@@ -32,7 +31,9 @@ const search = async (req, res, next) => {
promiseReview
=
promiseReview
.
filter
(
e
=>
typeof
(
e
)
===
'
string
'
)
promiseReview
=
promiseReview
.
filter
(
e
=>
typeof
(
e
)
===
'
string
'
)
reviews
.
forEach
(
async
(
review
,
i
)
=>
{
reviews
.
forEach
(
async
(
review
,
i
)
=>
{
review
[
"
content
"
]
=
promiseReview
[
i
]
review
[
"
content
"
]
=
promiseReview
[
i
]
const
reviews
=
new
Review
(
review
).
save
()
})
})
res
.
send
(
reviews
)
res
.
send
(
reviews
)
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
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