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
f6df8757
Commit
f6df8757
authored
Jan 13, 2021
by
Lee SeoYeon
Browse files
0113
parent
558b1436
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
client/.eslintcache
View file @
f6df8757
This diff is collapsed.
Click to expand it.
client/src/App.js
View file @
f6df8757
...
...
@@ -8,7 +8,7 @@ function App() {
const
[
state
,
setState
]
=
useState
(
false
);
const
[
search
,
setSearch
]
=
useState
(
""
);
const
user
=
isAuthenticated
()
if
(
state
!==
false
)
{
return
<
Redirect
to
=
{{
pathname
:
`/search/
${
search
}
`
,
...
...
@@ -26,13 +26,26 @@ function App() {
return
(
<
Container
className
=
"
vh-100 d-flex justify-content-md-center align-items-center
"
>
<
Col
md
=
{
6
}
lassName
=
"
d-flex justify-content-center
"
>
<
Col
md
=
{
6
}
style
=
{{
marginTop
:
140
}}
>
<
Row
style
=
{{
marginBottom
:
20
}}
>
<
Image
src
=
{
ohuh
}
/
>
<
/Row
>
<
Row
>
<
Navbar
bg
=
"
#fff
"
variant
=
"
light
"
>
<
Nav
className
=
"
mr-auto
"
>
{
user
?
<
Nav
.
Link
onClick
=
{()
=>
handleLogout
()}
>
로그아웃
<
/Nav.Link
>
:
(
<>
<
Nav
.
Link
href
=
"
/signup
"
>
회원가입
<
/Nav.Link
>
<
Nav
.
Link
href
=
"
/login
"
>
로그인
<
/Nav.Link
>
<
/
>
)}
<
/Nav
>
<
/Navbar
>
<
/Row
>
<
Row
style
=
{{
marginBottom
:
500
}}
>
<
Form
className
=
"
vw-100
"
onSubmit
=
{
handleSubmit
}
>
<
InputGroup
>
<
InputGroup
style
=
{{
width
:
560
}}
>
<
Form
.
Control
size
=
"
lg
"
placeholder
=
"
검색어를 입력하세요.
"
...
...
@@ -51,4 +64,4 @@ function App() {
);
}
export
default
App
;
\ No newline at end of file
export
default
App
;
client/src/Components/Signup.js
View file @
f6df8757
...
...
@@ -75,4 +75,4 @@ function Signup() {
)
}
export
default
Signup
\ No newline at end of file
export
default
Signup
server/config.js
View file @
f6df8757
...
...
@@ -3,6 +3,7 @@ const config = {
port
:
process
.
env
.
PORT
||
3001
,
jwtSecret
:
process
.
env
.
JWT_SECRET
||
'
My_Secret_Key
'
,
mongoDbUri
:
process
.
env
.
MONGODB_URI
||
'
mongodb://localhost/search-page
'
,
cookieMaxAge
:
60
*
60
*
24
*
7
*
1000
}
export
default
config
\ No newline at end of file
server/controllers/review.controller.js
View file @
f6df8757
import
Review
from
'
../models/Review.js
'
import
cheerio
from
"
cheerio
"
;
import
jschardet
from
'
jschardet
'
import
iconv
from
'
iconv
'
import
fs
from
'
fs
'
//
import jschardet from 'jschardet'
//
import iconv from 'iconv'
//
import fs from 'fs'
import
axios
from
'
axios
'
;
const
Iconv
=
iconv
.
Iconv
//
const Iconv = iconv.Iconv
const
search
=
async
(
req
,
res
)
=>
{
const
url
=
"
https://www.google.com/search?q=
"
+
encodeURI
(
req
.
params
.
search
)
+
"
+site%3Atistory.com&page_no=1
"
const
editUrl
=
/
(
http
(
s
)?
:
\/\/)([
a-z0-9
\w]
+
\.
*
)
+
[
a-z0-9
]{2,4}
/gi
axios
.
get
(
url
)
axios
.
get
(
url
)
// .then(anyToUtf8)
.
then
((
html
)
=>
{
// fs.writeFileSync("googlez.txt", '\ufeff' + html, { encoding: 'utf8' });
...
...
@@ -39,11 +39,11 @@ const search = async (req, res) => {
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
();
}
//
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 {
// const newPlace = await new Place({
// name: req.params.search,
...
...
server/server.js
View file @
f6df8757
...
...
@@ -2,6 +2,8 @@ import express from 'express'
import
connectDb
from
'
./utils/connectDb.js
'
import
placeRouter
from
'
./routes/place.routes.js
'
import
reviewRouter
from
'
./routes/review.routes.js
'
import
userRouter
from
"
./routes/user.routes.js
"
import
authRouter
from
"
./routes/auth.routes.js
"
connectDb
()
...
...
@@ -13,6 +15,8 @@ app.use(express.json())
app
.
use
(
placeRouter
)
app
.
use
(
reviewRouter
)
app
.
use
(
userRouter
)
app
.
use
(
authRouter
)
app
.
get
(
'
/
'
,
(
req
,
res
)
=>
{
console
.
log
(
"
/ req.body
"
,
req
.
body
)
...
...
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