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
Show 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'
import
{
Alert
,
Col
,
Card
,
Container
,
Form
,
Row
,
Button
,
Nav
,
Navbar
,
ListGroup
,
Image
,
Table
}
from
"
react-bootstrap
"
import
axios
from
"
axios
"
import
catchErrors
from
'
./utils/catchErrors.js
'
import
{
isAuthenticated
}
from
'
./utils/auth
'
import
{
Redirect
}
from
'
react-router-dom
'
const
INIT_PAGE
=
{
titl
e
:
''
,
url
:
''
,
nam
e
:
''
,
bookmark
:
[]
}
const
user
=
isAuthenticated
()
function
Bookmark
()
{
const
[
page
,
setPage
]
=
useState
(
INIT_PAGE
)
const
[
success
,
setSuccess
]
=
useState
(
false
)
const
[
error
,
setError
]
=
useState
(
''
)
function
handleChange
(
event
)
{
const
{
title
,
value
}
=
event
.
target
setPage
({...
page
,
[
title
]:
value
})
}
async
function
handleSubmit
(
event
)
{
event
.
preventDefault
()
try
{
setError
(
''
)
const
response
=
await
axios
.
post
(
'
/api/users/bookmark
'
,
page
)
console
.
log
(
response
.
data
)
const
response
=
await
axios
.
post
(
'
/api/users/bookmark
'
,
page
)
console
.
log
(
page
)
// setUser(INIT_USER)
setSuccess
(
true
)
}
catch
(
error
)
{
console
.
log
(
error
)
catchErrors
(
error
,
setError
)
}
}
const
add_Page
=
[{
title
:
'
즐겨찾기1
'
,
url
:
'
http://localhost:3000
'
,
},
{
title
:
'
즐겨찾기2
'
,
url
:
'
https://www.naver.com/
'
,
},
{
title
:
'
즐겨찾기3
'
,
url
:
'
https://www.youtube.com/watch?v=wo46N-LQK7o
'
}]
useEffect
(()
=>
{
Bookmark
(
user
)
},
[
user
])
return
(
<
Container
>
...
...
@@ -53,10 +42,6 @@ function Bookmark() {
<
Nav
className
=
"
mr-auto
"
>
<
Nav
.
Link
href
=
"
/
"
>
Home
<
/Nav.Link
>
<
/Nav
>
{
/* <Form inline>
<FormControl type="text" placeholder="Search" className="mr-sm-2" />
<Button variant="outline-light">Search</Button>
</Form> */
}
<
/Navbar
>
<
Form
>
<
ListGroup
>
...
...
client/src/Components/Place.js
View file @
c48ea233
...
...
@@ -3,18 +3,11 @@ import React, { useEffect, useState } from 'react';
import
{
Modal
,
Container
,
Row
,
Button
,
}
from
'
react-bootstrap
'
;
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
[
db
,
setDb
]
=
useState
(
false
)
const
getReview
=
()
=>
{
axios
({
url
:
`/api/review?keyword=
${
props
.
place
.
name
}
`
,
method
:
'
post
'
,
data
:
{
db
:
db
}
})
.
then
(
res
=>
{
>>>>>>>
origin
/
cherry
console
.
log
(
"
place res.data
"
,
res
.
data
)
setReviews
(
res
.
data
)
})
...
...
client/src/Search.js
View file @
c48ea233
...
...
@@ -5,7 +5,7 @@ import Place from './Components/Place';
import
{
Container
,
Form
,
Row
,
Col
,
Card
,
Image
,
InputGroup
,
FormControl
,
Button
,
Modal
}
from
'
react-bootstrap
'
;
import
Paginations
from
'
./Components/Paginations.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
"
;
const
INIT_PAGE
=
{
...
...
@@ -124,7 +124,7 @@ function Search(props) {
return
(
<
Col
key
=
{
index
}
md
=
{
6
}
>
<
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
>
<
Card
.
Img
variant
=
"
top
"
style
=
{{
padding
:
"
5%
"
,
width
:
"
100%
"
,
height
:
"
340px
"
}}
src
=
{
place
.
img
}
/
>
...
...
@@ -154,12 +154,3 @@ function Search(props) {
}
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) => {
places
[
i
]
=
{
name
:
$1
(
'
.biz_name
'
).
text
(),
category
:
$1
(
'
.category
'
).
text
(),
address
:
$1
(
'
.addr
'
).
text
()
}
})
}
}
)
}
const
searchImg
=
async
(
req
,
res
)
=>
{
...
...
@@ -64,7 +64,7 @@ const searchImg = async (req, res) => {
}
})
const
searchAssociation
=
async
(
req
,
res
)
=>
{
let
Place
=
await
Places
.
findOne
({
name
:
req
.
query
.
keyword
})
...
...
@@ -85,7 +85,7 @@ const searchAssociation = async (req, res) => {
// })
// console.log("Associations = ", Associations)
// 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
cheerio
from
"
cheerio
"
;
<<<<<<<
HEAD
import
fs
from
'
fs
'
import
axios
from
'
axios
'
;
...
...
@@ -16,14 +15,14 @@ const search = async (req, res, next) => {
fs
.
writeFileSync
(
"
googleSearch
"
,
response1
.
data
,
{
encoding
:
'
utf-8
'
})
// console.log(response1.data)
const
$1
=
cheerio
.
load
(
response1
.
data
);
const
$1
=
cheerio
.
load
(
response1
.
data
);
//cheerio? reponse1의 데이터를 로드하는거
$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
link
=
searchParams
.
get
(
"
/url?q
"
)
const
summary
=
$1
(
this
).
find
(
'
.s3v9rd
'
).
find
(
'
.s3v9rd
'
).
text
()
content
.
push
(
getReview
(
link
))
if
(
title
)
{
if
(
title
)
{
//타이틀일때 리뷰에 [i] 를 넣었을 때 타이틀, 링크값 설정
reviews
[
i
]
=
{
title
:
title
,
link
:
link
}
}
else
if
(
summary
)
{
reviews
[
i
-
1
]
=
{
...
reviews
[
i
-
1
],
summary
:
summary
}
...
...
@@ -38,55 +37,6 @@ const search = async (req, res, next) => {
}
catch
(
error
)
{
// console.log(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) => {
return
content
}
<<<<<<<
HEAD
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')
router
.
param
(
'
userId
'
,
userCtrl
.
userById
)
// router.get('/admin/:_id', verifyToken, function (req, res, next) {
// 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);
// })
// });
// router.route('/api/users/bookmark')
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