Commit 768b5382 authored by Kim, Chaerin's avatar Kim, Chaerin
Browse files

Merge remote-tracking branch 'origin/Sangjune' into cherry

parents 69d3e466 f5339224
...@@ -45,48 +45,6 @@ function Place(props) { ...@@ -45,48 +45,6 @@ function Place(props) {
})} })}
</Container> </Container>
{/* <Accordion defaultActiveKey="0">
<Accordion.Toggle as={Button} variant="link" eventKey="0">
<a className="mb-2">다음의 블로그 보기</a>
</Accordion.Toggle>
<Accordion.Collapse eventKey="0">
<Card.Body><div>주도 전역을 지배하는 한라산은 남한에서 가장 높은 산으로 높이는 1,947.3m이다. 한라산이라는 이름은 산이 높아 산정에 서면 은하수를 잡아당길 수 있다는 뜻이며, 부악·원산·선산·두무악·영주산·부라산·혈망봉·여장군 등으로도 불려왔다.</div></Card.Body>
</Accordion.Collapse>
<Row>
<Accordion.Toggle as={Button} variant="link" eventKey="1">
<a className="mb-2">네이버의 블로그 보기</a>
</Accordion.Toggle>
<Accordion.Collapse eventKey="1">
<Card.Body><div>한라산은 1966년 한라산 천연보호구역으로, 1970년 국립공원으로 지정되었다. 그리고 2002년에는 유네스코 생물권보전지역으로 지정되었으며 2007년에는 유네스코 세계자연유산으로 등재되었다. 2008년에는 물장오리오름 산정화구호 습지가 람사르 습지로 등록되어 보호 관리되고 있다</div></Card.Body>
</Accordion.Collapse>
</Row>
<Row>
<Accordion.Toggle as={Button} variant="link" eventKey="2">
<a className="mb-2">구글의 블로그 보기</a>
</Accordion.Toggle>
<Accordion.Collapse eventKey="2">
<Card.Body><div>한라산은 제주도에 있는 해발 1,947.06m, 면적 약 1,820km²의 화산으로, 제주도의 면적 대부분을 차지하고 있다. 정상에 백록담이라는 화산호가 있는데, 백록담이라는 이름은 흰 사슴이 물을 먹는 곳이라는 뜻에서 왔다고 전해진다.</div></Card.Body>
</Accordion.Collapse>
</Row>
</Accordion>
<Row style={{ color: 'white' }}>
<a href="https://www.daum.net/" className="mb-2">다음</a><a href="https://www.naver.com/" className="mb-2">네이버</a><a href="https://www.google.com/" className="mb-2">구글</a>
</Row>
// </Container>
<Carousel>
<Carousel.Item interval={1000}>
<h3>다음 블로그</h3>
<div>주도 전역을 지배하는 한라산은 남한에서 가장 높은 산으로 높이는 1,947.3m이다. 한라산이라는 이름은 산이 높아 산정에 서면 은하수를 잡아당길 수 있다는 뜻이며, 부악·원산·선산·두무악·영주산·부라산·혈망봉·여장군 등으로도 불려왔다.</div>
</Carousel.Item>
<Carousel.Item interval={1000}>
<h3>네이버 블로그</h3>
<div>한라산은 1966년 한라산 천연보호구역으로, 1970년 국립공원으로 지정되었다. 그리고 2002년에는 유네스코 생물권보전지역으로 지정되었으며 2007년에는 유네스코 세계자연유산으로 등재되었다. 2008년에는 물장오리오름 산정화구호 습지가 람사르 습지로 등록되어 보호 관리되고 있다</div>
</Carousel.Item>
<Carousel.Item interval={1000}>
<h3>구글 블로그</h3>
<div>한라산은 제주도에 있는 해발 1,947.06m, 면적 약 1,820km²의 화산으로, 제주도의 면적 대부분을 차지하고 있다. 정상에 백록담이라는 화산호가 있는데, 백록담이라는 이름은 흰 사슴이 물을 먹는 곳이라는 뜻에서 왔다고 전해진다.</div>
</Carousel.Item>
</Carousel> */}
</Modal.Body> </Modal.Body>
<Modal.Footer> <Modal.Footer>
<Button block onClick={props.onHide}>Close</Button> <Button block onClick={props.onHide}>Close</Button>
......
...@@ -4,6 +4,7 @@ import ohuh from '../ohuh-sm.PNG'; ...@@ -4,6 +4,7 @@ import ohuh from '../ohuh-sm.PNG';
import Place from '../Components/Place'; import Place from '../Components/Place';
import { Container, Form, Row, Col, Card, Image, InputGroup, FormControl, Button, Pagination } from 'react-bootstrap'; import { Container, Form, Row, Col, Card, Image, InputGroup, FormControl, Button, Pagination } from 'react-bootstrap';
import Paginations from '../Components/Paginations'; import Paginations from '../Components/Paginations';
import axios from 'axios';
function Search(props) { function Search(props) {
const endPage = 10; const endPage = 10;
...@@ -12,8 +13,49 @@ function Search(props) { ...@@ -12,8 +13,49 @@ function Search(props) {
const [showSet, setShowSet] = useState([false, false, false, false]); const [showSet, setShowSet] = useState([false, false, false, false]);
const [search, setSearch] = useState(props.location.state.id); const [search, setSearch] = useState(props.location.state.id);
const [mobile, setMobile] = useState(); const [mobile, setMobile] = useState();
const [place, setPlace] = useState([{ name: "", category: "", address: "" }])
const [imgUrl, setImgUrl] = useState([])
const [association, setAssociation] = useState([])
const getImg = () => {
axios.get(`/api/search/imges/${search}`)
.then(res => {
console.log("images=", res.data)
setImgUrl(res.data)
})
.catch(err => {
console.log('search.images 에러 발생', err)
})
}
const getPlace = () => {
axios.get(`/api/search/places/${search}`)
.then(res => {
console.log("places=", res.data)
setPlace(res.data)
})
.catch(err => {
console.log('search.places 에러 발생', err)
})
}
const getAssociation =() => {
axios.get(`/api/search/association/${search}`)
.then(res => {
console.log("Associations = ", res.data)
setAssociation(res.data)
})
.catch(err => {
console.log("search.associations 에러 발생", err)
})
}
useEffect(() => { useEffect(() => {
getPlace()
getImg()
getAssociation()
if (window.innerWidth < 960) { if (window.innerWidth < 960) {
setMobile(true) setMobile(true)
} else { } else {
...@@ -21,27 +63,31 @@ function Search(props) { ...@@ -21,27 +63,31 @@ function Search(props) {
} }
}, []); }, []);
const places = [{ const places = [{
name: "한라산", name: "한라산",
address: "제주 서귀포시 토평동 산15-1", address: "제주 서귀포시 토평동 산15-1",
img: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOUAAADcCAMAAAC4YpZBAAAAkFBMVEX4ugAAAAD8vQD/vwD/wQAAAAP9vQD2uQCwhAO9jgVAMAbmrANTPwYQDAONaQDQmwN2WQG3iwMyJwZAMACofgMKCAZOOwTHlgGFYwfwtAKYcgYpHwHXoQXepgTorgTxtQJjSgCgeAUgGANwVAUZEwJeRgOKaAR8XQRbRAcnHgQ3KgZPOwGrgQJINQZrUQYeFwOi9fVkAAAIi0lEQVR4nO2b2XaCSBCG6WpaRFTcIoKAIuJu8v5vN72BoOiYnEzEM/XdJEBD+Omllq4YBoIgCIIgCIIgCIIgCIIgCIIgC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Kmagw4HEKRJElZrBrCp/RtOWgbgBcZa8zFhwzOYu4yoNQY65IpjLl4AgLw1XK61zlXKXtBoVKQwxjdk5CB0Buzg5mkrTHmlDQLVWewziOnRjUFjtXuZMq+Sqj1w6LcYEPVYIzE6sqm/cjEEP6QjMSPyWvQMFVyu0tkxUFAVxl8lgln4ORt+XLLxk51CZkO9NsX186ISjbSwlXKdWZBzLVIzYUM/VxX8oSHzOaMbI0uXMRy3lJG5MxuKuSr5s9telhcouwMB6ptJKtysLzJetsmkzXskM4m0V/rKeeuyohZGQr/s8SvJUoc65Vaeg1NiPZQu4edcmO0j5ZxfJoU/6vv1dyV6Vh9Qn5tEM3WZNRBA/7Uiw4Wy8MvUDuzDsHMpp4obthpN0M50essVWVc60SfG4F2WjFo2uRDaCsULlSKlNRN0E7cvXhVvfj0PnifoXw3V3u3H0dVkX92suxguO2Mqro5zH/RzxqL4+jTjaTmRLYHU/yp3tcqs8SHCf8cHCUxsLOxqPROBtKXwesGT8cL5thLAX0uhKNXsrMwLRCJ7+en4fqCX0aIA7DuIgwKXXCBpXn/xvfqVy7Crh/+U0QBEEQBEEQBEEQBEEQBEEQBEEQBEEQBEEQBEEQBEEQBEEQBEEQBEEQBEEQBEEQBEGQ/yH/ALoViVlZW8doAAAAAElFTkSuQmCC", img: "https://upload.wikimedia.org/wikipedia/commons/thumb/e/eb/KOCIS_Halla_Mountain_in_Jeju-do_%286387785543%29.jpg/269px-KOCIS_Halla_Mountain_in_Jeju-do_%286387785543%29.jpg?size=200x200",
// img: "https://upload.wikimedia.org/wikipedia/commons/thumb/e/eb/KOCIS_Halla_Mountain_in_Jeju-do_%286387785543%29.jpg/269px-KOCIS_Halla_Mountain_in_Jeju-do_%286387785543%29.jpg?size=200x200", }, {
// }, { name: "성산일출봉(sungsan)",
// name: "성산일출봉(sungsan)", address: "제주 서귀포시 성산읍 성산리 1",
// address: "제주 서귀포시 성산읍 성산리 1", img: "https://www.jeju.go.kr/pub/site/geopark/images/sub/sub03/02%EC%A7%80%EC%A7%88%EB%A7%88%EC%9D%84%EC%9D%B4%EC%95%BC%EA%B8%B0/%EC%A7%80%EC%A7%88%EB%A7%88%EC%9D%84/%EC%A7%80%EC%A7%88%EB%A7%88%EC%9D%84_%EC%84%B1%EC%82%B0%EC%9D%BC%EC%B6%9C%EB%B4%89/1412402261.jpg?400/400",
// img: "https://www.jeju.go.kr/pub/site/geopark/images/sub/sub03/02%EC%A7%80%EC%A7%88%EB%A7%88%EC%9D%84%EC%9D%B4%EC%95%BC%EA%B8%B0/%EC%A7%80%EC%A7%88%EB%A7%88%EC%9D%84/%EC%A7%80%EC%A7%88%EB%A7%88%EC%9D%84_%EC%84%B1%EC%82%B0%EC%9D%BC%EC%B6%9C%EB%B4%89/1412402261.jpg?400/400", }, {
// }, { name: "해녀의 집(haenyeo)",
// name: "해녀의 집(haenyeo)", address: "제주 서귀포시 성산읍 한도로 141-13지번오조리 3 오조해녀의집",
// address: "제주 서귀포시 성산읍 한도로 141-13지번오조리 3 오조해녀의집", img: "https://mblogthumb-phinf.pstatic.net/MjAxNjExMTdfMTc0/MDAxNDc5MzU3ODU0ODQy.KZYXCjzsXT3rCsE4HXBfxyCg2buvluBvN_7NxVp7BSwg.loJc89d8JjGXdNCn-4yMd7aMWPjfrZn21TI9Hyzemkog.JPEG.icocam11/20161010_100205.jpg?type=w800",
// img: "https://mblogthumb-phinf.pstatic.net/MjAxNjExMTdfMTc0/MDAxNDc5MzU3ODU0ODQy.KZYXCjzsXT3rCsE4HXBfxyCg2buvluBvN_7NxVp7BSwg.loJc89d8JjGXdNCn-4yMd7aMWPjfrZn21TI9Hyzemkog.JPEG.icocam11/20161010_100205.jpg?type=w800", }, {
// }, { name: "오설록 티 뮤지엄(osulloc)",
// name: "오설록 티 뮤지엄(osulloc)", address: "제주 서귀포시 안덕면 신화역사로 15 오설록지번서광리 1235-1 오설록",
// address: "제주 서귀포시 안덕면 신화역사로 15 오설록지번서광리 1235-1 오설록", img: "https://cdnweb01.wikitree.co.kr/webdata/editor/202007/01/img_20200701143323_2ced7627.webp",
// img: "https://cdnweb01.wikitree.co.kr/webdata/editor/202007/01/img_20200701143323_2ced7627.webp", }, {
// }, { name: "오설록 티 뮤지엄(osulloc)",
// name: "오설록 티 뮤지엄(osulloc)", address: "제주 서귀포시 안덕면 신화역사로 15 오설록지번서광리 1235-1 오설록",
// address: "제주 서귀포시 안덕면 신화역사로 15 오설록지번서광리 1235-1 오설록", img: "https://upload.wikimedia.org/wikipedia/commons/thumb/e/eb/KOCIS_Halla_Mountain_in_Jeju-do_%286387785543%29.jpg/269px-KOCIS_Halla_Mountain_in_Jeju-do_%286387785543%29.jpg",
// img: "https://upload.wikimedia.org/wikipedia/commons/thumb/e/eb/KOCIS_Halla_Mountain_in_Jeju-do_%286387785543%29.jpg/269px-KOCIS_Halla_Mountain_in_Jeju-do_%286387785543%29.jpg",
}] }]
if (state !== false) { if (state !== false) {
...@@ -73,7 +119,17 @@ function Search(props) { ...@@ -73,7 +119,17 @@ function Search(props) {
return page return page
} }
const pagePlace = paginate(places, index, 1) const pagePlace = paginate(association, index, association.length)
// function times (){
// let time = new Date()
// console.log(time)
// return time
// }
// console.log(times())
let time = new Date()
return ( return (
<Container > <Container >
...@@ -94,6 +150,28 @@ function Search(props) { ...@@ -94,6 +150,28 @@ function Search(props) {
</InputGroup> </InputGroup>
</Form> </Form>
</Row> </Row>
{/* {time.toString()}**** */}
{time.toLocaleString()}****
{/* {time.toLocaleDateString()}****
{time.toLocaleTimeString()}**** */}
<Col md={6} >
<Card align="center" border="info" style={{ margin: "3%" }}>
<Card.Title style={{ margin: "3%", fontSize: '200%', fontWeight: 'bold' }} >{place[0].name}</Card.Title>
<Card.Img variant="top" style={{ padding: "5%", width: "100%", height: "340px" }} src={imgUrl} />
<Card.Body >
<Card.Text style={{ overflow: 'auto', fontSize: '25px', width: '100%', height: "80px" }} >
{place[0].address}{place[0].category} </Card.Text>
<Button variant="primary" onClick={() => {
// const showArr = [false, false, false, false]
// showArr[index] = true
// setShowSet(showArr)
}}>{place[0].name} 자세히 살펴보기</Button>
{/* <Place search={place} show={show} onHide={() => setShowSet([false, false, false, false])} /> */}
</Card.Body>
</Card>
</Col>
<Row className="d-flex flex-wrap"> <Row className="d-flex flex-wrap">
{pagePlace.map((place, index) => { {pagePlace.map((place, index) => {
return ( return (
...@@ -116,13 +194,12 @@ function Search(props) { ...@@ -116,13 +194,12 @@ function Search(props) {
) )
})} })}
</Row> </Row>
{console.log(showSet)} {/* {console.log(showSet)} */}
{/* show가 전부 true로 바뀌어서 전부 다 보이게 되는 것이다. */} {/* show가 전부 true로 바뀌어서 전부 다 보이게 되는 것이다. */}
<Row className="mt-2 d-flex justify-content-center"> <Row className="mt-2 d-flex justify-content-center">
<Paginations index={index} endPage={endPage} handlePage={handlePage}></Paginations> <Paginations index={index} endPage={endPage} handlePage={handlePage}></Paginations>
</Row> </Row>
</Container> </Container>
); );
} }
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
import Place from '../models/Place.js' import Places from '../models/Place.js'
import cheerio from 'cheerio' import cheerio from 'cheerio'
import fs from 'fs'
import axios from 'axios';
import { time } from 'console';
const signup = async (req, res) => { const searchPlace = async (req, res) => {
const { name, email, password } = req.body
console.log(name, email, password) const url = "https://search.naver.com/search.naver?sm=tab_hty.top&where=nexearch&query=" + encodeURI(req.params.search)
try { const editUrl = /(http(s)?:\/\/)([a-z0-9\w]+\.*)+[a-z0-9]{2,4}/gi
if (!isLength(name, { min: 3, max: 10 })) { axios.get(url)
return res.status(422).send('Name must be 3-10 characters') .then(async (response) => {
} const html = response.data
const newUser = await new User({ // console.log(html)
name, fs.writeFileSync("googleReview", html, { encoding: 'utf-8' })
email, let $1 = cheerio.load(html);
password
}).save() let places = {}
console.log(newUser) $1('.ct_box_area').each(function (i) {
res.json(newUser)
} catch (error) {
console.log(error) // console.log($1('.biz_name').text())
res.status(500).send('User signup error') // console.log($1('.category').text())
} // console.log($1('.addr').text())
// console.log($1('.t?ime highlight').text())
places[i] = { name: $1('.biz_name').text(), category: $1('.category').text(), address: $1('.addr').text() }
})
// 값이 비어있거나 에러가 생겼을 때를 대비해 try catch를 해야함
const newPlaces = await new Places(places[0]
).save()
res.send(places)
})
} }
const search = async (req, res) => { const searchImg = async (req, res) => {
// 정보들 크롤링 해오고 아래에 넣어주기 const imgUrl = "https://www.google.com/search?q=" + encodeURI(req.params.search) + "+site:tistory.com/&sxsrf=ALeKk023Dv08KQDodRmpB5222lQuzw2Vaw:1610612821100&source=lnms&tbm=isch"
const url = "https://section.blog.naver.com/Search/Post.nhn?keyword=" + keyword axios.get(imgUrl)
request(url, function (err, res, html) { // URL로부터 가져온 페이지 소스가 html이란 변수에 담긴다. .then(async (response) => {
if (!err) { const html = response.data
var $ = cheerio.load(html); let name = req.params.search
let $1 = cheerio.load(html);
// 블로그 title 정보 가져오기 let images = $1('.RAyV4b').find('img').attr('src')
$(".entry-title > a").each(function () {
var post = { "name": "", "address": "", "img": "" };
var data = $(this);
post["title"] = data.text(); // let images = []
post["link"] = data.attr("href");
}); // $1('.RAyV4b').each(function (i) {
} // images[i] = { imgUrl: $(this).find('img').atrr('src') }
// })
// console.log('%%%%%%%%%%%%%%%%%%%%%%%%%%%', images)
// 여기서 있는건 찾아와서 추가를 시켜야한다.
//사진만 업데이트
let Place = await Places.findOne({ name: req.params.search })
Place.times.push(new Date().toLocaleString())
await Places.updateOne({ name: req.params.search }, { img: images, times: Place.times })
const newPlaces = await new Places(
).save()
res.send(images)
}) })
// try { }
// const newPlace = await new Place({
// name: req.params.search,
// address,
// img,
const searchAssociation = async (req, res) => {
let Place = await Places.findOne({ name: req.params.search })
let address = Place.address.split(' ')[0]
// let AssociationsId = []
let addressPlaces = new RegExp(`${address}`)
let responsePlaces = await Places.find({ address: addressPlaces })
res.send(responsePlaces)
// responsePlaces.map(Association => {
// AssociationsId.push(Association._id)
// }) // })
// } // console.log("Associations = ", Associations)
// res.send(AssociationsId)
} }
export default { signup, search }
\ No newline at end of file export default { searchImg, searchPlace, searchAssociation }
import Review from '../models/Review.js' import Review from '../models/Review.js'
import cheerio, { html } from "cheerio"; import cheerio from "cheerio";
import iconv from 'iconv' import iconv from 'iconv'
import fs from 'fs' import fs from 'fs'
import axios from 'axios'; import axios from 'axios';
...@@ -41,6 +41,24 @@ const search = async (req, res, next) => { ...@@ -41,6 +41,24 @@ const search = async (req, res, next) => {
} }
} }
//***************네이버 크롤링 할 때 ********************* */
// try {
// let reviews = []
// let content = []
// const url = "https://search.naver.com/search.naver?where=view&sm=tab_jum&query=" + encodeURI('한라산')
// const response1 = await axios.get(url)
// // console.log(response1.data)
// const $1 = cheerio.load(response1.data);
// $1('._list').find('.total_wrap').each(async function (i) {
// reviews[i] = { name: $1(this).find('.total_tit').text(), summery: $1(this).find('.dsc_txt').text(), link: $1(this).find('.total_tit').attr('href') }
// })
// res.send(reviews)
// } catch (error) {
// console.log(error)
// res.send(error)
// }
// }
const getReview = async (link) => { const getReview = async (link) => {
if (link) { if (link) {
let content = '없음' let content = '없음'
...@@ -50,8 +68,11 @@ const getReview = async (link) => { ...@@ -50,8 +68,11 @@ const getReview = async (link) => {
content = $2('.tt_article_useless_p_margin').text() content = $2('.tt_article_useless_p_margin').text()
} }
return content return content
console.log(content, link)
} }
} }
export default { search, getReview } const find = (res,req,next) => {
\ No newline at end of file Review.find({address: })
}
export default { search, find }
\ No newline at end of file
...@@ -25,8 +25,15 @@ const PlaceSchema = new mongoose.Schema({ ...@@ -25,8 +25,15 @@ const PlaceSchema = new mongoose.Schema({
type: Array, type: Array,
required: true, required: true,
}, },
category: {
type: String,
},
times: {
type: Array
},
}, { }, {
timestamps: true timestamps: true
}) })
export default mongoose.models.Place || mongoose.model('Place', PlaceSchema) export default mongoose.models.Places || mongoose.model('Place', PlaceSchema)
\ No newline at end of file
...@@ -3,8 +3,13 @@ import place from '../controllers/place.controller.js' ...@@ -3,8 +3,13 @@ import place from '../controllers/place.controller.js'
const router = express.Router() const router = express.Router()
router.route('/api/search/:search') router.route('/api/search/imges/:search')
.post(place.signup) .get(place.searchImg)
.get(place.search)
router.route('/api/search/places/:search')
.get(place.searchPlace)
router.route('/api/search/association/:search')
.get(place.searchAssociation)
export default router export default router
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment