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
c48ea233
Commit
c48ea233
authored
Jan 25, 2021
by
Lee SeoYeon
Browse files
.
parent
f4598802
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
client/.eslintcache
View file @
c48ea233
This diff is collapsed.
Click to expand it.
client/src/Bookmark.js
View file @
c48ea233
...
@@ -2,49 +2,38 @@ import React, { useState, useEffect } from 'react'
...
@@ -2,49 +2,38 @@ import React, { useState, useEffect } from 'react'
import
{
Alert
,
Col
,
Card
,
Container
,
Form
,
Row
,
Button
,
Nav
,
Navbar
,
ListGroup
,
Image
,
Table
}
from
"
react-bootstrap
"
import
{
Alert
,
Col
,
Card
,
Container
,
Form
,
Row
,
Button
,
Nav
,
Navbar
,
ListGroup
,
Image
,
Table
}
from
"
react-bootstrap
"
import
axios
from
"
axios
"
import
axios
from
"
axios
"
import
catchErrors
from
'
./utils/catchErrors.js
'
import
catchErrors
from
'
./utils/catchErrors.js
'
import
{
isAuthenticated
}
from
'
./utils/auth
'
import
{
Redirect
}
from
'
react-router-dom
'
import
{
Redirect
}
from
'
react-router-dom
'
const
INIT_PAGE
=
{
const
INIT_PAGE
=
{
titl
e
:
''
,
nam
e
:
''
,
url
:
''
,
bookmark
:
[]
}
}
const
user
=
isAuthenticated
()
function
Bookmark
()
{
function
Bookmark
()
{
const
[
page
,
setPage
]
=
useState
(
INIT_PAGE
)
const
[
page
,
setPage
]
=
useState
(
INIT_PAGE
)
const
[
success
,
setSuccess
]
=
useState
(
false
)
const
[
error
,
setError
]
=
useState
(
''
)
const
[
error
,
setError
]
=
useState
(
''
)
function
handleChange
(
event
)
{
const
{
title
,
value
}
=
event
.
target
setPage
({...
page
,
[
title
]:
value
})
}
async
function
handleSubmit
(
event
)
{
async
function
handleSubmit
(
event
)
{
event
.
preventDefault
()
event
.
preventDefault
()
try
{
try
{
setError
(
''
)
setError
(
''
)
const
response
=
await
axios
.
post
(
'
/api/users/bookmark
'
,
page
)
const
response
=
await
axios
.
post
(
'
/api/users/bookmark
'
,
page
)
console
.
log
(
response
.
data
)
console
.
log
(
page
)
console
.
log
(
page
)
// setUser(INIT_USER)
// setUser(INIT_USER)
setSuccess
(
true
)
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
error
)
console
.
log
(
error
)
catchErrors
(
error
,
setError
)
catchErrors
(
error
,
setError
)
}
}
}
}
const
add_Page
=
[{
useEffect
(()
=>
{
title
:
'
즐겨찾기1
'
,
Bookmark
(
user
)
url
:
'
http://localhost:3000
'
,
},
[
user
])
},
{
title
:
'
즐겨찾기2
'
,
url
:
'
https://www.naver.com/
'
,
},
{
title
:
'
즐겨찾기3
'
,
url
:
'
https://www.youtube.com/watch?v=wo46N-LQK7o
'
}]
return
(
return
(
<
Container
>
<
Container
>
...
@@ -53,10 +42,6 @@ function Bookmark() {
...
@@ -53,10 +42,6 @@ function Bookmark() {
<
Nav
className
=
"
mr-auto
"
>
<
Nav
className
=
"
mr-auto
"
>
<
Nav
.
Link
href
=
"
/
"
>
Home
<
/Nav.Link
>
<
Nav
.
Link
href
=
"
/
"
>
Home
<
/Nav.Link
>
<
/Nav
>
<
/Nav
>
{
/* <Form inline>
<FormControl type="text" placeholder="Search" className="mr-sm-2" />
<Button variant="outline-light">Search</Button>
</Form> */
}
<
/Navbar
>
<
/Navbar
>
<
Form
>
<
Form
>
<
ListGroup
>
<
ListGroup
>
...
...
client/src/Components/Place.js
View file @
c48ea233
...
@@ -3,18 +3,11 @@ import React, { useEffect, useState } from 'react';
...
@@ -3,18 +3,11 @@ import React, { useEffect, useState } from 'react';
import
{
Modal
,
Container
,
Row
,
Button
,
}
from
'
react-bootstrap
'
;
import
{
Modal
,
Container
,
Row
,
Button
,
}
from
'
react-bootstrap
'
;
function
Place
(
props
)
{
function
Place
(
props
)
{
<<<<<<<
HEAD
const
[
reviews
,
setReviews
]
=
useState
([{
title
:
""
,
link
:
""
,
summery
:
""
,
content
:
""
}])
const
getReview
=
()
=>
{
axios
.
get
(
`/api/review/
${
props
.
search
.
name
}
`
)
//review를 서버에 연결해서
.
then
(
res
=>
{
s
=======
const
[
reviews
,
setReviews
]
=
useState
()
const
[
reviews
,
setReviews
]
=
useState
()
const
[
db
,
setDb
]
=
useState
(
false
)
const
[
db
,
setDb
]
=
useState
(
false
)
const
getReview
=
()
=>
{
const
getReview
=
()
=>
{
axios
({
url
:
`/api/review?keyword=
${
props
.
place
.
name
}
`
,
method
:
'
post
'
,
data
:
{
db
:
db
}
})
axios
({
url
:
`/api/review?keyword=
${
props
.
place
.
name
}
`
,
method
:
'
post
'
,
data
:
{
db
:
db
}
})
.
then
(
res
=>
{
.
then
(
res
=>
{
>>>>>>>
origin
/
cherry
console
.
log
(
"
place res.data
"
,
res
.
data
)
console
.
log
(
"
place res.data
"
,
res
.
data
)
setReviews
(
res
.
data
)
setReviews
(
res
.
data
)
})
})
...
...
client/src/Search.js
View file @
c48ea233
...
@@ -5,7 +5,7 @@ import Place from './Components/Place';
...
@@ -5,7 +5,7 @@ import Place from './Components/Place';
import
{
Container
,
Form
,
Row
,
Col
,
Card
,
Image
,
InputGroup
,
FormControl
,
Button
,
Modal
}
from
'
react-bootstrap
'
;
import
{
Container
,
Form
,
Row
,
Col
,
Card
,
Image
,
InputGroup
,
FormControl
,
Button
,
Modal
}
from
'
react-bootstrap
'
;
import
Paginations
from
'
./Components/Paginations.js
'
import
Paginations
from
'
./Components/Paginations.js
'
import
catchErrors
from
'
./utils/catchErrors.js
'
import
catchErrors
from
'
./utils/catchErrors.js
'
import
*
as
Icon
from
'
react-bootstrap-icons
'
;
//
import * as Icon from 'react-bootstrap-icons';
import
axios
from
"
axios
"
;
import
axios
from
"
axios
"
;
const
INIT_PAGE
=
{
const
INIT_PAGE
=
{
...
@@ -124,7 +124,7 @@ function Search(props) {
...
@@ -124,7 +124,7 @@ function Search(props) {
return
(
return
(
<
Col
key
=
{
index
}
md
=
{
6
}
>
<
Col
key
=
{
index
}
md
=
{
6
}
>
<
Card
align
=
"
center
"
border
=
"
info
"
style
=
{{
margin
:
"
3%
"
}}
>
<
Card
align
=
"
center
"
border
=
"
info
"
style
=
{{
margin
:
"
3%
"
}}
>
<
Button
onSubmit
=
{
handleSubmit
}
variant
=
"
outline-info
"
style
=
{{
marginLeft
:
"
55vh
"
}}
type
=
'
submit
'
><
Icon
.
BookmarkStar
size
=
{
30
}
/></
Button
>
{
/*
<Button onSubmit={handleSubmit} variant="outline-info" style={{ marginLeft: "55vh" }} type='submit'><Icon.BookmarkStar size={30} /></Button>
*/
}
<
Card
.
Title
style
=
{{
margin
:
"
3%
"
,
fontSize
:
'
200%
'
,
fontWeight
:
'
bold
'
}}
>
{
place
.
name
}
<
Card
.
Title
style
=
{{
margin
:
"
3%
"
,
fontSize
:
'
200%
'
,
fontWeight
:
'
bold
'
}}
>
{
place
.
name
}
<
/Card.Title
>
<
/Card.Title
>
<
Card
.
Img
variant
=
"
top
"
style
=
{{
padding
:
"
5%
"
,
width
:
"
100%
"
,
height
:
"
340px
"
}}
src
=
{
place
.
img
}
/
>
<
Card
.
Img
variant
=
"
top
"
style
=
{{
padding
:
"
5%
"
,
width
:
"
100%
"
,
height
:
"
340px
"
}}
src
=
{
place
.
img
}
/
>
...
@@ -154,12 +154,3 @@ function Search(props) {
...
@@ -154,12 +154,3 @@ function Search(props) {
}
}
export
default
Search
export
default
Search
// async function saveId(bookmarkId) {
// await axios.put('/api/users', {userId:userId, bookmarkId:bookmarkId})
// }
// const bookmarksave = async (req, res) => {
// const {userId, bookmarkId} = req.body
// let bookmark = await Bookmark.findOne({bookmarkId:bookmarkId}).select('user')
// }
server/controllers/place.controller.js
View file @
c48ea233
...
@@ -26,7 +26,7 @@ const searchPlace = async (req, res) => {
...
@@ -26,7 +26,7 @@ const searchPlace = async (req, res) => {
places
[
i
]
=
{
name
:
$1
(
'
.biz_name
'
).
text
(),
category
:
$1
(
'
.category
'
).
text
(),
address
:
$1
(
'
.addr
'
).
text
()
}
places
[
i
]
=
{
name
:
$1
(
'
.biz_name
'
).
text
(),
category
:
$1
(
'
.category
'
).
text
(),
address
:
$1
(
'
.addr
'
).
text
()
}
})
})
}
}
)
}
}
const
searchImg
=
async
(
req
,
res
)
=>
{
const
searchImg
=
async
(
req
,
res
)
=>
{
...
@@ -38,24 +38,24 @@ const searchImg = async (req, res) => {
...
@@ -38,24 +38,24 @@ const searchImg = async (req, res) => {
let
name
=
req
.
query
.
keyword
let
name
=
req
.
query
.
keyword
let
$1
=
cheerio
.
load
(
html
);
let
$1
=
cheerio
.
load
(
html
);
axios
.
get
(
imgUrl
)
axios
.
get
(
imgUrl
)
.
then
(
async
(
response
)
=>
{
.
then
(
async
(
response
)
=>
{
const
html
=
response
.
data
const
html
=
response
.
data
let
name
=
req
.
params
.
search
let
name
=
req
.
params
.
search
let
$1
=
cheerio
.
load
(
html
);
let
$1
=
cheerio
.
load
(
html
);
let
images
=
$1
(
'
.RAyV4b
'
).
find
(
'
img
'
).
attr
(
'
src
'
)
let
images
=
$1
(
'
.RAyV4b
'
).
find
(
'
img
'
).
attr
(
'
src
'
)
//사진만 업데이트
//사진만 업데이트
let
Place
=
await
Places
.
findOne
({
name
:
req
.
params
.
search
})
let
Place
=
await
Places
.
findOne
({
name
:
req
.
params
.
search
})
Place
.
times
.
push
(
new
Date
().
toLocaleString
())
Place
.
times
.
push
(
new
Date
().
toLocaleString
())
await
Places
.
updateOne
({
name
:
req
.
params
.
search
},
{
img
:
images
,
times
:
Place
.
times
})
await
Places
.
updateOne
({
name
:
req
.
params
.
search
},
{
img
:
images
,
times
:
Place
.
times
})
const
newPlaces
=
await
new
Places
(
const
newPlaces
=
await
new
Places
(
).
save
()
).
save
()
res
.
send
(
images
)
res
.
send
(
images
)
})
})
//사진만 업데이트
//사진만 업데이트
let
Place
=
await
Places
.
findOne
({
name
:
req
.
query
.
keyword
})
let
Place
=
await
Places
.
findOne
({
name
:
req
.
query
.
keyword
})
...
@@ -64,28 +64,28 @@ const searchImg = async (req, res) => {
...
@@ -64,28 +64,28 @@ const searchImg = async (req, res) => {
}
})
const
searchAssociation
=
async
(
req
,
res
)
=>
{
const
searchAssociation
=
async
(
req
,
res
)
=>
{
let
Place
=
await
Places
.
findOne
({
name
:
req
.
query
.
keyword
})
let
Place
=
await
Places
.
findOne
({
name
:
req
.
query
.
keyword
})
if
(
!
Place
)
{
if
(
!
Place
)
{
res
.
send
([])
res
.
send
([])
}
}
let
addresse
=
Place
.
address
.
split
(
'
'
)[
0
]
let
addresse
=
Place
.
address
.
split
(
'
'
)[
0
]
// let AssociationsId = []
// let AssociationsId = []
let
addressPlaces
=
new
RegExp
(
`
${
addresse
}
`
)
let
addressPlaces
=
new
RegExp
(
`
${
addresse
}
`
)
let
responsePlaces
=
await
Places
.
find
({
address
:
addressPlaces
})
let
responsePlaces
=
await
Places
.
find
({
address
:
addressPlaces
})
res
.
send
(
responsePlaces
)
res
.
send
(
responsePlaces
)
// responsePlaces.map(Association => {
// responsePlaces.map(Association => {
// AssociationsId.push(Association._id)
// AssociationsId.push(Association._id)
// })
// })
// console.log("Associations = ", Associations)
// console.log("Associations = ", Associations)
// res.send(AssociationsId)
// res.send(AssociationsId)
}
}
export
default
{
searchImg
,
searchPlace
,
searchAssociation
}
export
default
{
searchImg
,
searchPlace
,
searchAssociation
}
server/controllers/review.controller.js
View file @
c48ea233
import
Review
from
'
../models/Review.js
'
import
Review
from
'
../models/Review.js
'
import
cheerio
from
"
cheerio
"
;
import
cheerio
from
"
cheerio
"
;
<<<<<<<
HEAD
import
fs
from
'
fs
'
import
fs
from
'
fs
'
import
axios
from
'
axios
'
;
import
axios
from
'
axios
'
;
...
@@ -16,14 +15,14 @@ const search = async (req, res, next) => {
...
@@ -16,14 +15,14 @@ const search = async (req, res, next) => {
fs
.
writeFileSync
(
"
googleSearch
"
,
response1
.
data
,
{
encoding
:
'
utf-8
'
})
fs
.
writeFileSync
(
"
googleSearch
"
,
response1
.
data
,
{
encoding
:
'
utf-8
'
})
// console.log(response1.data)
// console.log(response1.data)
const
$1
=
cheerio
.
load
(
response1
.
data
);
const
$1
=
cheerio
.
load
(
response1
.
data
);
//cheerio? reponse1의 데이터를 로드하는거
$1
(
'
.kCrYT
'
).
each
(
async
function
(
i
)
{
$1
(
'
.kCrYT
'
).
each
(
async
function
(
i
)
{
const
title
=
$1
(
this
).
find
(
'
h3
'
).
text
()
const
title
=
$1
(
this
).
find
(
'
h3
'
).
text
()
//타이틀에 텍스트 안에 h3값을 찾는다?
const
searchParams
=
new
URLSearchParams
(
$1
(
this
).
find
(
'
a
'
).
attr
(
'
href
'
));
const
searchParams
=
new
URLSearchParams
(
$1
(
this
).
find
(
'
a
'
).
attr
(
'
href
'
));
const
link
=
searchParams
.
get
(
"
/url?q
"
)
const
link
=
searchParams
.
get
(
"
/url?q
"
)
const
summary
=
$1
(
this
).
find
(
'
.s3v9rd
'
).
find
(
'
.s3v9rd
'
).
text
()
const
summary
=
$1
(
this
).
find
(
'
.s3v9rd
'
).
find
(
'
.s3v9rd
'
).
text
()
content
.
push
(
getReview
(
link
))
content
.
push
(
getReview
(
link
))
if
(
title
)
{
if
(
title
)
{
//타이틀일때 리뷰에 [i] 를 넣었을 때 타이틀, 링크값 설정
reviews
[
i
]
=
{
title
:
title
,
link
:
link
}
reviews
[
i
]
=
{
title
:
title
,
link
:
link
}
}
else
if
(
summary
)
{
}
else
if
(
summary
)
{
reviews
[
i
-
1
]
=
{
...
reviews
[
i
-
1
],
summary
:
summary
}
reviews
[
i
-
1
]
=
{
...
reviews
[
i
-
1
],
summary
:
summary
}
...
@@ -38,55 +37,6 @@ const search = async (req, res, next) => {
...
@@ -38,55 +37,6 @@ const search = async (req, res, next) => {
}
catch
(
error
)
{
}
catch
(
error
)
{
// console.log(error)
// console.log(error)
// res.send(error)
// res.send(error)
=======
import
axios
from
'
axios
'
;
const
search
=
async
(
req
,
res
,
next
)
=>
{
console
.
log
(
"
1
"
)
for
(
let
i
=
1
;
(
req
.
reviews
).
length
>
10
;
i
++
)
{
try
{
console
.
log
(
"
2
"
)
let
reviews
=
[]
let
content
=
[]
const
url
=
"
https://www.google.com/search?q=
"
+
encodeURI
(
req
.
query
.
keyword
)
+
"
+site%3Atistory.com&page_no=
"
+
i
const
response1
=
await
axios
.
get
(
url
)
// console.log(response1.data)
const
$1
=
cheerio
.
load
(
response1
.
data
);
$1
(
'
.kCrYT
'
).
each
(
async
function
(
i
)
{
console
.
log
(
"
3
"
)
const
title
=
$1
(
this
).
find
(
'
h3
'
).
text
()
const
searchParams
=
new
URLSearchParams
(
$1
(
this
).
find
(
'
a
'
).
attr
(
'
href
'
));
const
link
=
searchParams
.
get
(
"
/url?q
"
)
const
summary
=
$1
(
this
).
find
(
'
.s3v9rd
'
).
find
(
'
.s3v9rd
'
).
text
()
Review
.
find
({
link
:
link
},
function
(
err
,
review
)
{
if
(
!
review
)
{
content
.
push
(
getReview
(
link
))
if
(
title
)
{
reviews
[
i
]
=
{
title
:
title
,
link
:
link
}
}
else
if
(
summary
)
{
reviews
[
i
-
1
]
=
{
...
reviews
[
i
-
1
],
summary
:
summary
}
reviews
=
reviews
.
filter
(
e
=>
e
)
}
}
})
})
let
promiseReview
=
await
Promise
.
all
(
content
)
promiseReview
=
promiseReview
.
filter
(
e
=>
typeof
(
e
)
===
'
string
'
)
reviews
.
forEach
(
async
(
review
,
i
)
=>
{
console
.
log
(
"
4
"
)
review
[
"
content
"
]
=
promiseReview
[
i
]
const
reviews
=
new
Review
(
review
).
save
()
reviews
.
keyword
.
push
(
req
.
query
.
keyword
)
req
.
reviews
.
push
(
reviews
)
})
console
.
log
(
"
5
"
)
res
.
send
(
reviews
)
}
catch
(
error
)
{
console
.
log
(
"
6
"
)
console
.
log
(
error
)
res
.
send
(
error
)
}
>>>>>>>
origin
/
cherry
}
}
}
}
...
@@ -122,23 +72,5 @@ const getReview = async (link) => {
...
@@ -122,23 +72,5 @@ const getReview = async (link) => {
return
content
return
content
}
}
<<<<<<<
HEAD
export
default
{
search
,
getReview
}
export
default
{
search
,
getReview
}
=======
const
find
=
(
req
,
res
,
next
)
=>
{
console
.
log
(
"
7
"
,
req
.
body
)
if
(
req
.
body
.
db
)
{
next
()
}
Review
.
find
({
keyword
:{
$elemMatch
:
res
.
query
.
keyword
}
},
function
(
err
,
reviews
)
{
if
(
reviews
)
{
if
(
reviews
.
length
>
10
)
res
.
send
(
reviews
,
{
db
:
true
})
req
.
reviews
=
reviews
}
next
()
})
}
export
default
{
search
,
find
}
>>>>>>>
origin
/
cherry
server/routes/user.routes.js
View file @
c48ea233
...
@@ -8,14 +8,6 @@ router.route('/api/users/signup')
...
@@ -8,14 +8,6 @@ router.route('/api/users/signup')
router
.
param
(
'
userId
'
,
userCtrl
.
userById
)
router
.
param
(
'
userId
'
,
userCtrl
.
userById
)
// router.get('/admin/:_id', verifyToken, function (req, res, next) {
// router.route('/api/users/bookmark')
// console.log('/reserves/admin get req.params', req.params)
// Reserve.find({ approve: false }).populate('user').exec(function (err, reserve) {
// if (err) return res.status(500).json({ error: err });
// console.log('reserve list', reserve)
// res.status(201).json(reserve);
// })
// });
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