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
380f73b7
Commit
380f73b7
authored
Jan 13, 2021
by
baesangjune
Browse files
review
parent
c8e037b0
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
client/.eslintcache
View file @
380f73b7
This diff is collapsed.
Click to expand it.
client/debug.log
View file @
380f73b7
[0111/154710.316:ERROR:directory_reader_win.cc(43)] FindFirstFile: 지정된 경로를 찾을 수 없습니다. (0x3)
[0112/191834.168:ERROR:directory_reader_win.cc(43)] FindFirstFile: 지정된 경로를 찾을 수 없습니다. (0x3)
client/src/Components/Place.js
View file @
380f73b7
...
...
@@ -7,6 +7,7 @@ function Place(props) {
const
getReview
=
()
=>
{
axios
.
get
(
`/api/review/
${
props
.
search
.
name
}
`
)
.
then
(
res
=>
{
console
.
log
(
"
res.data=
"
,
res
.
data
)
setReviews
(
res
.
data
)
})
.
catch
(
err
=>
{
...
...
@@ -42,9 +43,9 @@ function Place(props) {
<
/Row
>
)
})}
<
/Container
>
<
/Container
>
{
/* <Accordion defaultActiveKey="0">
{
/* <Accordion defaultActiveKey="0">
<Accordion.Toggle as={Button} variant="link" eventKey="0">
<a className="mb-2">다음의 블로그 보기</a>
</Accordion.Toggle>
...
...
server/controllers/review.controller.js
View file @
380f73b7
...
...
@@ -3,48 +3,44 @@ import cheerio from "cheerio";
import
express
from
'
express
'
;
import
request
from
'
request-promise
'
import
jschardet
from
'
jschardet
'
import
iconv
from
'
iconv
'
//
import iconv from 'iconv'
import
fs
from
'
fs
'
const
Iconv
=
iconv
.
Iconv
//
const Iconv = iconv.Iconv
const
signup
=
async
(
req
,
res
)
=>
{
res
.
send
(
"
안녕하세요
"
)
}
const
search
=
async
(
req
,
res
)
=>
{
const
url
=
"
https://www.google.com/search?q=
"
+
encodeURI
(
req
.
params
.
search
)
+
"
+site%3Atistory.com
"
+
'
&page_no=1
'
// console.log(req.params.search)
// console.log("req", req)
const
url
=
"
https://www.google.com/search?q=%ED%95%9C%EB%9D%BC%EC%82%B0%20site%3Atistory.com&oq=tistory&aqs=chrome..69i57j0l4j69i60l3.1746j0j4&sourceid=chrome&ie=UTF-8&ved=2ahUKEwis_bSFz4buAhWVdXAKHU0tBaoQ2wF6BAgIEAE&ei=T1D1X-yZD5XrwQPN2pTQCg
"
// const url=
request
(
url
)
.
then
(
anyToUtf8
)
//
.then(anyToUtf8)
.
then
((
html
)
=>
{
// fs.writeFileSync("googlez.txt", '\ufeff' + html, { encoding: 'utf8' });
let
$
=
cheerio
.
load
(
html
,
null
,
false
);
let
places
=
[]
$
(
'
.kCrYT
'
).
each
(
function
(
i
)
{
const
review
=
await
Review
.
findOne
({
link
:
$
(
this
).
find
(
'
a
'
).
attr
(
'
href
'
)
})
if
(
!
user
)
{
const
newReview
=
await
new
Review
({
name
,
email
,
password
:
hash
}).
save
()
}
places
[
i
]
=
{
title
:
$
(
this
).
find
(
'
h3
'
).
text
(),
link
:
$
(
this
).
find
(
'
a
'
).
attr
(
'
href
'
),
summary
:
$
(
this
).
find
(
'
.s3v9rd
'
).
text
(),
summary
:
$
(
this
).
find
(
'
.s3v9rd
'
).
find
(
'
.s3v9rd
'
).
text
(),
}
})
// console.log(places)
console
.
log
(
"
places***********************************************
"
,
places
)
res
.
send
(
places
)
})
function
anyToUtf8
(
str
)
{
const
{
encoding
}
=
jschardet
.
detect
(
str
);
console
.
log
(
"
source encoding =
"
+
encoding
);
const
iconv
=
new
Iconv
(
encoding
,
"
utf-8//translit//ignore
"
);
return
iconv
.
convert
(
str
).
toString
();
}
// function anyToUtf8(str) {
// const { encoding } = jschardet.detect(str);
// console.log("source encoding = " + encoding);
// const iconv = new Iconv(encoding, "utf-8//translit//ignore");
// return iconv.convert(str).toString();
// }
// try {
// const newPlace = await new Place({
// name: req.params.search,
...
...
@@ -55,6 +51,4 @@ const search = async (req, res) => {
// }
}
const
export
default
{
signup
,
search
}
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