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
4223171e
Commit
4223171e
authored
Jan 13, 2021
by
baesangjune
Browse files
Merge remote-tracking branch 'origin/cherry' into Sangjune
parents
380f73b7
9168132d
Changes
4
Hide whitespace changes
Inline
Side-by-side
client/src/Components/Place.js
View file @
4223171e
...
@@ -19,7 +19,6 @@ function Place(props) {
...
@@ -19,7 +19,6 @@ function Place(props) {
getReview
();
getReview
();
},
[])
},
[])
return
(
return
(
<
Modal
{...
props
}
<
Modal
{...
props
}
size
=
"
xl
"
size
=
"
xl
"
...
...
client/src/Pages/App.js
View file @
4223171e
...
@@ -22,31 +22,30 @@ function App() {
...
@@ -22,31 +22,30 @@ function App() {
setState
(
true
);
setState
(
true
);
}
}
return
(
return
(
<
Container
className
=
"
vh-100
"
>
<
Container
className
=
"
vh-100 d-flex justify-content-md-center align-items-center
"
>
<
Row
className
=
"
d-flex justify-content-md-center
"
>
<
Col
md
=
{
6
}
lassName
=
"
d-flex justify-content-center
"
>
<
Col
md
=
{
6
}
className
=
"
mt-5
"
>
<
Row
style
=
{{
marginBottom
:
20
}}
>
<
Image
src
=
{
ohuh
}
fluid
/>
<
Image
src
=
{
ohuh
}
/
>
<
/Col
>
<
/Row
>
<
Col
lg
=
{{
span
:
10
,
offset
:
1
}}
>
<
Row
style
=
{{
marginBottom
:
500
}}
>
<
InputGroup
size
=
"
lg
"
lg
=
{
6
}
xs
=
{
4
}
fluid
>
<
Form
className
=
"
vw-100
"
onSubmit
=
{
handleSubmit
}
>
<
FormControl
<
InputGroup
>
className
=
"
d-flex justify-content-lg-center
"
<
Form
.
Control
placeholder
=
"
검색어를 입력하세요.
"
size
=
"
lg
"
aria
-
label
=
"
Large
"
placeholder
=
"
검색어를 입력하세요.
"
aria
-
describedby
=
"
inputGroup-sizing-sm
"
aria
-
label
=
"
Large
"
onChange
=
{
handleChange
}
aria
-
describedby
=
"
inputGroup-sizing-sm
"
/
>
onChange
=
{
handleChange
}
<
InputGroup
.
Append
>
/
>
<
Button
variant
=
"
outline-secondary
"
onClick
=
{
handleSubmit
}
>
검색
<
/Button
>
<
InputGroup
.
Append
>
<
/InputGroup.Append
>
<
Button
type
=
'
submit
'
variant
=
"
outline-secondary
"
>
검색
<
/Button
>
<
/InputGroup
>
<
/InputGroup.Append
>
<
/Col
>
<
/InputGroup
>
<
/Row
>
<
/Form
>
<
/Row
>
<
/Col
>
<
/Container
>
<
/Container
>
);
);
}
}
...
...
server/controllers/review.controller.js
View file @
4223171e
import
Review
from
'
../models/Review.js
'
import
Review
from
'
../models/Review.js
'
import
cheerio
from
"
cheerio
"
;
import
cheerio
from
"
cheerio
"
;
import
express
from
'
express
'
;
import
request
from
'
request-promise
'
import
jschardet
from
'
jschardet
'
import
jschardet
from
'
jschardet
'
// import iconv from 'iconv'
// import iconv from 'iconv'
import
fs
from
'
fs
'
import
fs
from
'
fs
'
// const Iconv = iconv.Iconv
import
axios
from
'
axios
'
;
const
Iconv
=
iconv
.
Iconv
const
signup
=
async
(
req
,
res
)
=>
{
res
.
send
(
"
안녕하세요
"
)
}
const
search
=
async
(
req
,
res
)
=>
{
const
search
=
async
(
req
,
res
)
=>
{
// console.log(req.params.search)
const
url
=
"
https://www.google.com/search?q=
"
+
encodeURI
(
req
.
params
.
search
)
+
"
+site%3Atistory.com&page_no=1
"
// console.log("req", req)
const
editUrl
=
/
(
http
(
s
)?
:
\/\/)([
a-z0-9
\w]
+
\.
*
)
+
[
a-z0-9
]{2,4}
/gi
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
"
axios
.
get
(
url
)
// const url=
request
(
url
)
// .then(anyToUtf8)
// .then(anyToUtf8)
.
then
((
html
)
=>
{
.
then
((
html
)
=>
{
// fs.writeFileSync("googlez.txt", '\ufeff' + html, { encoding: 'utf8' });
// fs.writeFileSync("googlez.txt", '\ufeff' + html, { encoding: 'utf8' });
let
$1
=
cheerio
.
load
(
html
.
data
);
let
$
=
cheerio
.
load
(
html
,
null
,
false
);
let
reviews
=
[]
let
places
=
[]
$1
(
'
.kCrYT
'
).
each
(
function
(
i
)
{
$
(
'
.kCrYT
'
).
each
(
function
(
i
)
{
let
link
=
""
places
[
i
]
=
{
if
(
$1
(
this
).
find
(
'
a
'
).
attr
(
'
href
'
))
{
title
:
$
(
this
).
find
(
'
h3
'
).
text
(),
link
=
(
$1
(
this
).
find
(
'
a
'
).
attr
(
'
href
'
)).
match
(
editUrl
)
link
:
$
(
this
).
find
(
'
a
'
).
attr
(
'
href
'
),
}
summary
:
$
(
this
).
find
(
'
.s3v9rd
'
).
find
(
'
.s3v9rd
'
).
text
(),
reviews
[
i
]
=
{
title
:
$1
(
this
).
find
(
'
h3
'
).
text
(),
link
:
link
,
summary
:
$1
(
this
).
find
(
'
.s3v9rd
'
).
text
(),
}
}
})
})
console
.
log
(
"
places***********************************************
"
,
places
)
// reviews.forEach((review, i) => {
res
.
send
(
places
)
// axios.get(review.link)
})
// .then((html) => {
// function anyToUtf8(str) {
// let $2 = cheerio.load(html.data);
// const { encoding } = jschardet.detect(str);
// $2('').each(function(i){
// console.log("source encoding = " + encoding);
// review.content($2(this).find(''.text()))
// const iconv = new Iconv(encoding, "utf-8//translit//ignore");
// })
// return iconv.convert(str).toString();
// })
// }
// })
console
.
log
(
reviews
)
res
.
send
(
reviews
)
})
function
anyToUtf8
(
str
)
{
const
{
encoding
}
=
jschardet
.
detect
(
str
);
// 웹페이지 문서의 인코딩 타입을 확인
const
iconv
=
new
Iconv
(
encoding
,
"
utf-8//translit//ignore
"
);
// euc-kr 인코딩변환
return
iconv
.
convert
(
str
).
toString
();
}
// try {
// try {
// const newPlace = await new Place({
// const newPlace = await new Place({
// name: req.params.search,
// name: req.params.search,
...
@@ -51,4 +54,5 @@ const search = async (req, res) => {
...
@@ -51,4 +54,5 @@ const search = async (req, res) => {
// }
// }
}
}
export
default
{
signup
,
search
}
export
default
{
search
}
server/routes/review.routes.js
View file @
4223171e
...
@@ -4,7 +4,6 @@ import review from '../controllers/review.controller.js'
...
@@ -4,7 +4,6 @@ import review from '../controllers/review.controller.js'
const
router
=
express
.
Router
()
const
router
=
express
.
Router
()
router
.
route
(
'
/api/review/:search
'
)
router
.
route
(
'
/api/review/:search
'
)
.
post
(
review
.
signup
)
.
get
(
review
.
search
)
.
get
(
review
.
search
)
export
default
router
export
default
router
\ No newline at end of file
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