Commit 72dcf80a authored by Lee SeoYeon's avatar Lee SeoYeon
Browse files

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

parents a2a2ee7f 768b5382
# Getting Started with Create React App
# Getting Started with Create React App
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
......
[0111/154710.316:ERROR:directory_reader_win.cc(43)] FindFirstFile: 지정된 경로를 찾을 수 없습니다. (0x3)
[0112/191834.168:ERROR:directory_reader_win.cc(43)] FindFirstFile: 지정된 경로를 찾을 수 없습니다. (0x3)
[0114/234147.078:ERROR:directory_reader_win.cc(43)] FindFirstFile: 지정된 경로를 찾을 수 없습니다. (0x3)
......@@ -19,7 +19,6 @@ function Place(props) {
getReview();
}, [])
return (
<Modal {...props}
size="xl"
......
import React from "react";
import { Route, Switch } from "react-router-dom";
import Home from "./home/Home";
import Main from "./home/Main";
function MainRouter() {
return (
<div>
{/* <Main /> */}
<Switch>
<Route exact path="/">
<Main />
</Route>
<Route path="/main">
<Main />
</Route>
{/* <Route path="/signup">
<Signup />
</Route> */}
</Switch>
</div>
);
}
export default MainRouter;
import React, { useState, useEffect } from 'react';
import { Link, Redirect } from 'react-router-dom';
import ohuh from '../ohuh-sm.PNG';
import Place from '../Components/Place';
import { Container, Form, Row, Col, Card, Image, InputGroup, FormControl, Button, Pagination } from 'react-bootstrap';
import Paginations from '../Components/Paginations';
import axios from 'axios';
function Search(props) {
const endPage = 10;
const [state, setState] = useState(false);
const [index, setIndex] = useState(1);
const [showSet, setShowSet] = useState([false, false, false, false]);
const [search, setSearch] = useState(props.location.state.id);
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(() => {
getPlace()
getImg()
getAssociation()
if (window.innerWidth < 960) {
setMobile(true)
} else {
setMobile(false)
}
}, []);
const places = [{
name: "한라산",
address: "제주 서귀포시 토평동 산15-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?size=200x200",
}, {
name: "성산일출봉(sungsan)",
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",
}, {
name: "해녀의 집(haenyeo)",
address: "제주 서귀포시 성산읍 한도로 141-13지번오조리 3 오조해녀의집",
img: "https://mblogthumb-phinf.pstatic.net/MjAxNjExMTdfMTc0/MDAxNDc5MzU3ODU0ODQy.KZYXCjzsXT3rCsE4HXBfxyCg2buvluBvN_7NxVp7BSwg.loJc89d8JjGXdNCn-4yMd7aMWPjfrZn21TI9Hyzemkog.JPEG.icocam11/20161010_100205.jpg?type=w800",
}, {
name: "오설록 티 뮤지엄(osulloc)",
address: "제주 서귀포시 안덕면 신화역사로 15 오설록지번서광리 1235-1 오설록",
img: "https://cdnweb01.wikitree.co.kr/webdata/editor/202007/01/img_20200701143323_2ced7627.webp",
}, {
name: "오설록 티 뮤지엄(osulloc)",
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",
}]
if (state !== false) {
return <Redirect to={{
pathname: `/search/${search}`,
state: { id: search },
}} />;
}
const handlePage = (num) => {
setIndex(num);
}
const handleChange = (e) => {
setSearch(e.target.value);
}
const handleSubmit = (e) => {
setState(true);
}
function paginate(items, pageNumber, itemNumber) {
const page = [];
const startIndex = (pageNumber - 1) * itemNumber
for (var i = 0; i < itemNumber; i++) {
page.push(items[(startIndex + i)])
}
return page
}
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 (
<Container >
<Link to="/" className="d-flex justify-content-center"><Image src={ohuh} /></Link>
<Row className="mb-2" className="d-flex justify-content-center">
<Form style={{ width: "90vw" }} onSubmit={handleSubmit}>
<InputGroup size="lg">
<FormControl
placeholder="검색어를 입력하세요."
value={search}
aria-label="Large"
aria-describedby="inputGroup-sizing-sm"
onChange={handleChange}
/>
<InputGroup.Append>
<Button type="submit" variant="outline-secondary" >검색</Button>
</InputGroup.Append>
</InputGroup>
</Form>
</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">
{pagePlace.map((place, index) => {
return (
<Col key={index} md={6} >
<Card align="center" border="info" style={{ margin: "3%" }}>
<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} />
<Card.Body >
<Card.Text style={{ overflow: 'auto', fontSize: '25px', width: '100%', height: "80px" }} >
{place.address} </Card.Text>
<Button variant="primary" onClick={() => {
const showArr = [false, false, false, false]
showArr[index] = true
setShowSet(showArr)
}}>{place.name} 자세히 살펴보기</Button>
<Place search={place} index={index} show={showSet[index]} onHide={() => setShowSet([false, false, false, false])} />
</Card.Body>
</Card>
</Col>
)
})}
</Row>
{/* {console.log(showSet)} */}
{/* show가 전부 true로 바뀌어서 전부 다 보이게 되는 것이다. */}
<Row className="mt-2 d-flex justify-content-center">
<Paginations index={index} endPage={endPage} handlePage={handlePage}></Paginations>
</Row>
</Container>
);
}
export default Search;
import React from "react";
import Button from "react-bootstrap/Button";
import Form from "react-bootstrap/Form";
import Container from "react-bootstrap/Container";
// import { Link } from "react-router-dom";
import { Redirect } from "react-router-dom";
import Row from "react-bootstrap/Row";
import Col from "react-bootstrap/Col";
import Image from 'react-bootstrap/Image'
import mainlogo from '../picture/mainlogo.jpg'
// import Modal from "react-bootstrap/Modal";
// import 'bootstrap / dist / css / bootstrap.min.css';
function Home() {
const clickSubmit = (event) => {
event.preventDefault();
console.log("버튼실행 = 메인으로 넘기기 ")
return <Redirect to="/main"/>
};
// if (values.redirect) {
// return <Redirect to="/" />;
// }
return (
<Container className="col-sm-6 col-md-5 col-lg-4 p-5">
{/* <Row> */}
<Image src={mainlogo} rounded />
<Form>
<Form.Group controlId="inputbox">
<Form.Label>오늘! 어디가?</Form.Label>
<Form.Control
/>
<Form.Text className="text-muted">
관광지를 입력하면 관련된 정보들이 나옵니다.
</Form.Text>
</Form.Group>
<Button variant="danger" type="submit" onClick={clickSubmit}>관광지 검색하기</Button>
</Form>
{/* </Row> */}
</Container>
);
}
export default Home;
import React from "react";
import Button from "react-bootstrap/Button";
import Form from "react-bootstrap/Form";
import Container from "react-bootstrap/Container";
import { Link } from "react-router-dom";
import { Redirect } from "react-router-dom";
import Row from "react-bootstrap/Row";
import Col from "react-bootstrap/Col";
import Image from 'react-bootstrap/Image'
import { Card } from 'react-bootstrap'
// import Modal from "react-bootstrap/Modal";
// import 'bootstrap / dist / css / bootstrap.min.css';
import mainlogo from '../picture/mainlogo.jpg'
import hallasan from '../picture/hallasan.PNG'
import osulloc from '../picture/osulloc.PNG'
import sungsan from '../picture/sungsan.PNG'
import haenyeo from '../picture/haenyeo.PNG'
function Main() {
const clickSubmit = (event) => {
event.preventDefault();
console.log("메인페이지 도착")
};
// if (values.redirect) {
// return <Redirect to="/" />;
// }
return (
<Container className="">
<Form>
<Image src={mainlogo} rounded />
<Form.Label>made by Cherry </Form.Label>
<Form.Group controlId="contentsbox">
<Form.Text>관광지 정보</Form.Text>
{/* <Form.Control
/> */}
<Row>
<Card style={{ width: '30rem' }}>
<Card.Img variant="top" src={hallasan} />
<Card.Body>
<Card.Title>한라산(hallasan)</Card.Title>
<Card.Text>
제주 서귀포시 토평동 산15-1 </Card.Text>
<Link to="/">
<Button variant="primary">한라산 자세히 살펴보기</Button>
</Link>
</Card.Body>
</Card>
<Card style={{ width: '30rem' }}>
<Card.Img variant="top" src={sungsan} />
<Card.Body>
<Card.Title>성산일출봉(sungsan)</Card.Title>
<Card.Text>
제주 서귀포시 성산읍 성산리 1 </Card.Text>
<Link to="/">
<Button variant="primary">성산일출봉 자세히 살펴보기</Button>
</Link>
</Card.Body>
</Card>
</Row>
<Row>
<Card style={{ width: '30rem' }}>
<Card.Img variant="top" src={haenyeo} />
<Card.Body>
<Card.Title>해녀의 집(haenyeo)</Card.Title>
<Card.Text>
제주 서귀포시 성산읍 한도로 141-13지번오조리 3 오조해녀의집 </Card.Text>
<Link to="/">
<Button variant="primary">해녀의 집 자세히 살펴보기</Button>
</Link>
</Card.Body>
</Card>
{/* modal같이 다른 창 띄우는 것도 방법이고 링크 넣거나 화면하나 만드는 것도 방법일 듯 */}
<Card style={{ width: '30rem' }}>
<Card.Img variant="top" src={osulloc} />
<Card.Body>
<Card.Title>오설록 티 뮤지엄(osulloc)</Card.Title>
<Card.Text>
제주 서귀포시 안덕면 신화역사로 15 오설록지번서광리 1235-1 오설록 </Card.Text>
<Link to="/">
<Button variant="primary">오설록 티 뮤지엄 자세히 살펴보기</Button>
</Link>
</Card.Body>
</Card>
</Row>
</Form.Group>
{/* <Button variant="primary" type="submit" onClick={clickSubmit}>Submit</Button> */}
{/* <Form.Group controlId="inputbox">
<Form.Label>다른 관광지 검색하기</Form.Label>
<Form.Control
/>
<Form.Text className="text-muted">
새로운 관광지를 검색합니다.
</Form.Text>
</Form.Group>
<Button variant="danger" type="submit" onClick={clickSubmit}>다른 관광지 검색하기</Button> */}
</Form>
</Container >
);
}
export default Main;
......@@ -16,7 +16,9 @@ import {
Redirect,
} from "react-router-dom";
// axios.defaults.validateStatus = function (status) {
// return status < 500; // default
// }
ReactDOM.render(
<React.StrictMode>
......
import { Pagination } from "react-bootstrap";
import React from 'react';
function Paginations(props) {
// console.log(props)
// const [index, setIndex] = useState(1);
return (
<Pagination>
<Pagination.First onClick={() => props.handlePage(1)} />
{props.index === 1 ? <Pagination.Prev onClick={()=>props.handlePage(props.index)} /> : <Pagination.Prev onClick={()=>props.handlePage(props.index - 1)} />}
{props.index === props.endPage-1 ? <Pagination.Item onClick={()=>props.handlePage(props.index - 3)}>{props.index - 3}</Pagination.Item> : ""}
{props.index === props.endPage ? <Pagination.Item onClick={()=>props.handlePage(props.index - 4)}>{props.index - 4}</Pagination.Item> : ""}
{props.index === props.endPage ? <Pagination.Item onClick={()=>props.handlePage(props.index - 3)}>{props.index - 3}</Pagination.Item> : ""}
{props.index < 3 ? "" : <Pagination.Item onClick={()=>props.handlePage(props.index - 2)}>{props.index - 2}</Pagination.Item>}
{props.index === 1 ? "" : <Pagination.Item onClick={()=>props.handlePage(props.index - 1)}>{props.index - 1}</Pagination.Item>}
<Pagination.Item active>{props.index}</Pagination.Item>
{props.index === props.endPage ? "" : <Pagination.Item onClick={()=>props.handlePage(props.index + 1)}>{props.index + 1}</Pagination.Item>}
{props.index > props.endPage-2 ? "" : <Pagination.Item onClick={()=>props.handlePage(props.index + 2)}>{props.index + 2}</Pagination.Item>}
{props.index === 1 ? <Pagination.Item onClick={()=>props.handlePage(props.index + 3)}>{props.index + 3}</Pagination.Item> : ""}
{props.index === 1 ? <Pagination.Item onClick={()=>props.handlePage(props.index + 4)}>{props.index + 4}</Pagination.Item> : ""}
{props.index === 2 ? <Pagination.Item onClick={()=>props.handlePage(props.index + 3)}>{props.index + 3}</Pagination.Item> : ""}
{props.index === props.endPage ? <Pagination.Next onClick={()=>props.handlePage(props.index)} /> : <Pagination.Next onClick={()=>props.handlePage(props.index + 1)} />}
<Pagination.Last onClick={() =>props.handlePage(props.endPage)} />
</Pagination>
)
}
export default Paginations
\ No newline at end of file
// import React from 'react';
// import { Row, Col, Card, Button } from "react-bootstrap";
// import Place from './Components/Place';
// function Quadrant(props) {
// <Row className="d-flex flex-wrap">
// <Col md={6} >
// <Card align="center" border="info" style={{ margin: "3%" }}>
// <Card.Title style={{ margin: "3%", fontSize: '200%', fontWeight: 'bold' }} >{props.pagePlace[0].name}</Card.Title>
// <Card.Img variant="top" style={{ padding: "5%", width: "100%", height: "340px" }} src={props.pagePlace[0].img} />
// <Card.Body >
// <Card.Text style={{ overflow: 'auto', fontSize: '25px', width: '100%', height: "80px" }} >
// {props.pagePlace[0].address} </Card.Text>
// <Button variant="primary" onClick={() => props.handleShow(true)}>{props.pagePlace[0].name} 자세히 살펴보기</Button>
// <Place search={props.pagePlace[0]} onHide={() => props.handleShow(false)} />
// </Card.Body>
// </Card>
// </Col>
// <Col md={6} >
// <Card align="center" border="info" style={{ margin: "3%" }}>
// <Card.Title style={{ margin: "3%", fontSize: '200%', fontWeight: 'bold' }} >{props.pagePlace[1].name}</Card.Title>
// <Card.Img variant="top" style={{ padding: "5%", width: "100%", height: "340px" }} src={props.pagePlace[1].img} />
// <Card.Body >
// <Card.Text style={{ overflow: 'auto', fontSize: '25px', width: '100%', height: "80px" }} >
// {props.pagePlace[0].address} </Card.Text>
// <Button variant="primary" onClick={() => props.handleShow(true)}>{props.pagePlace[0].name} 자세히 살펴보기</Button>
// <Place search={props.pagePlace[0]} onHide={() => props.handleShow(false)} />
// </Card.Body>
// </Card>
// </Col>
// <Col md={6} >
// <Card align="center" border="info" style={{ margin: "3%" }}>
// <Card.Title style={{ margin: "3%", fontSize: '200%', fontWeight: 'bold' }} >{props.pagePlace[0].name}</Card.Title>
// <Card.Img variant="top" style={{ padding: "5%", width: "100%", height: "340px" }} src={props.pagePlace[0].img} />
// <Card.Body >
// <Card.Text style={{ overflow: 'auto', fontSize: '25px', width: '100%', height: "80px" }} >
// {props.pagePlace[0].address} </Card.Text>
// <Button variant="primary" onClick={() => props.handleShow(true)}>{props.pagePlace[0].name} 자세히 살펴보기</Button>
// <Place search={props.pagePlace[0]} onHide={() => props.handleShow(false)} />
// </Card.Body>
// </Card>
// </Col>
// <Col md={6} >
// <Card align="center" border="info" style={{ margin: "3%" }}>
// <Card.Title style={{ margin: "3%", fontSize: '200%', fontWeight: 'bold' }} >{props.pagePlace[0].name}</Card.Title>
// <Card.Img variant="top" style={{ padding: "5%", width: "100%", height: "340px" }} src={props.pagePlace[0].img} />
// <Card.Body >
// <Card.Text style={{ overflow: 'auto', fontSize: '25px', width: '100%', height: "80px" }} >
// {props.pagePlace[0].address} </Card.Text>
// <Button variant="primary" onClick={() => props.handleShow(true)}>{props.pagePlace[0].name} 자세히 살펴보기</Button>
// <Place search={props.pagePlace[0]} onHide={() => props.handleShow(false)} />
// </Card.Body>
// </Card>
// </Col>
// </Row>
// }
// export default Quadrant
\ No newline at end of file
import Review from '../models/Review.js'
import cheerio from "cheerio";
// import iconv from 'iconv'
import fs from 'fs'
import axios from 'axios';
// const Iconv = iconv.Iconv
const search = async (req, res, next) => {
//**************************구글 크롤링 할 때************************/
try {
let reviews = []
let content = []
Review.find()
const url = "https://www.google.com/search?q=" + encodeURI(req.params.search) + "+site%3Atistory.com&page_no=1"
const response1 = await axios.get(url)
fs.writeFileSync("googleSearch", response1.data, { encoding: 'utf-8' })
// console.log(response1.data)
const $1 = cheerio.load(response1.data);
$1('.kCrYT').each(async function (i) {
......@@ -32,19 +27,20 @@ const search = async (req, res, next) => {
reviews = reviews.filter(e => e)
}
})
const promiseReview = await Promise.all(content)
let promiseReview = await Promise.all(content)
promiseReview = promiseReview.filter(e => typeof (e) === 'string')
reviews.forEach(async (review, i) => {
review["content"] = promiseReview[i]
const reviews = new Review(review).save()
})
res.send(reviews)
} catch (error) {
// console.log(error)
console.log(error)
res.send(error)
}
}
//***************네이버 크롤링 할 때 ********************* */
// try {
// let reviews = []
......@@ -64,16 +60,19 @@ const search = async (req, res, next) => {
// }
const getReview = async (link) => {
let content = '없음'
if (link) {
let content = '없음'
const res = await axios.get(link)
const $2 = cheerio.load(res.data);
if ($2('.tt_article_useless_p_margin').text()) {
content = $2('.tt_article_useless_p_margin').text()
}
}
return content
}
}
export default { search, getReview }
const find = (res,req,next) => {
Review.find({address: })
}
export default { search, find }
<p style="font-size: 1.12em;"><b>안녕하세요 화갱입니다. ㅎㅅㅎ</b></p>
<p style="font-size: 1.12em;">제주도하면 가장 먼저 떠오르는 관광명소가 있죠, 바로 <span style="color: #009a87;"><b>한라산</b></span>입니다. 성산일출봉, 우도, 월정, 애월 등 많은 관광지가 있지만 제주도의 <b>가장 원조적이고 유명한 관광명소는 한라산</b>입니다. 한라산은 <b>해발 1950m</b>로<b> 대한민국에서 가장 높은산</b>입니다. 1970년 국립공원으로 지정되어 2002년 유네스코 생물권보전지역으로 설정되었으며 <b>2007년에는 유네스코 세계자연유산</b>으로 선정되었습니다. 관리사무소도 어리목, 성판악, 영실, 관음사, 돈내코의 5개가 운영되고 있으며 대피소도 윗세오름, 진달래밭, 삼각봉, 속밭, 평궤의 5개가 운영중에 있습니다. 그리고 모든 코스마다 안내 및 표지만, 응급의약품 등 탐방하기에도 안전한 곳입니다. 오늘은 제가 직접 오른 등반코스와 다른 코스 추천 등 한라산 등산코스에 대해 리뷰해보겠습니다. 그럼 시작합니다.</p>
\ No newline at end of file
This diff is collapsed.
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