Commit b62079ad authored by Kim, Chaerin's avatar Kim, Chaerin
Browse files

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

parents 820d064e ed33bfcb
[{"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\reportWebVitals.js":"1","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\Search.js":"2","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\index.js":"3","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Components\\Place.js":"4","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Components\\Paginations.js":"5","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\App.js":"6"},{"size":362,"mtime":1608689675665,"results":"7","hashOfConfig":"8"},{"size":8185,"mtime":1611669626936,"results":"9","hashOfConfig":"8"},{"size":889,"mtime":1611497488080,"results":"10","hashOfConfig":"8"},{"size":2548,"mtime":1611668355580,"results":"11","hashOfConfig":"8"},{"size":2199,"mtime":1610325754517,"results":"12","hashOfConfig":"8"},{"size":1456,"mtime":1611495914736,"results":"13","hashOfConfig":"8"},{"filePath":"14","messages":"15","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1n20xnc",{"filePath":"16","messages":"17","errorCount":0,"warningCount":7,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"18","messages":"19","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":"20"},{"filePath":"21","messages":"22","errorCount":0,"warningCount":8,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"23","messages":"24","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"25","messages":"26","errorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\reportWebVitals.js",[],"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\Search.js",["27","28","29","30","31","32","33"],"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\index.js",["34","35"],"import React from 'react';\r\nimport ReactDOM from 'react-dom';\r\nimport './index.css';\r\nimport 'bootstrap/dist/css/bootstrap.min.css';\r\nimport App from './Pages/App';\r\nimport Search from './Pages/Search';\r\nimport axios from 'axios';\r\nimport reportWebVitals from './reportWebVitals';\r\nimport {\r\n BrowserRouter as Router,\r\n Switch,\r\n Route,\r\n Redirect,\r\n} from \"react-router-dom\";\r\n\r\nReactDOM.render(\r\n <React.StrictMode>\r\n <Router>\r\n <Switch>\r\n <Route exact path=\"/\" component={App} />\r\n <Route path=\"/search\" component={Search} />\r\n </Switch>\r\n </Router>\r\n </React.StrictMode>,\r\n document.getElementById('root')\r\n);\r\n\r\n// If you want to start measuring performance in your app, pass a function\r\n// to log results (for example: reportWebVitals(console.log))\r\n// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals\r\nreportWebVitals();\r\n","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Components\\Place.js",["36","37","38","39","40","41","42","43"],"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Components\\Paginations.js",[],"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\App.js",["44","45","46"],{"ruleId":"47","severity":1,"message":"48","line":2,"column":16,"nodeType":"49","messageId":"50","endLine":2,"endColumn":24},{"ruleId":"47","severity":1,"message":"51","line":16,"column":12,"nodeType":"49","messageId":"50","endLine":16,"endColumn":18},{"ruleId":"47","severity":1,"message":"52","line":17,"column":12,"nodeType":"49","messageId":"50","endLine":17,"endColumn":17},{"ruleId":"47","severity":1,"message":"53","line":18,"column":12,"nodeType":"49","messageId":"50","endLine":18,"endColumn":18},{"ruleId":"54","severity":1,"message":"55","line":78,"column":8,"nodeType":"56","endLine":78,"endColumn":15,"suggestions":"57"},{"ruleId":"47","severity":1,"message":"58","line":81,"column":11,"nodeType":"49","messageId":"50","endLine":81,"endColumn":17},{"ruleId":"59","severity":1,"message":"60","line":144,"column":35,"nodeType":"61","endLine":144,"endColumn":76},{"ruleId":"47","severity":1,"message":"62","line":7,"column":8,"nodeType":"49","messageId":"50","endLine":7,"endColumn":13},{"ruleId":"47","severity":1,"message":"48","line":13,"column":3,"nodeType":"49","messageId":"50","endLine":13,"endColumn":11},{"ruleId":"47","severity":1,"message":"63","line":3,"column":33,"nodeType":"49","messageId":"50","endLine":3,"endColumn":36},{"ruleId":"47","severity":1,"message":"64","line":3,"column":46,"nodeType":"49","messageId":"50","endLine":3,"endColumn":51},{"ruleId":"47","severity":1,"message":"65","line":3,"column":53,"nodeType":"49","messageId":"50","endLine":3,"endColumn":57},{"ruleId":"47","severity":1,"message":"66","line":3,"column":59,"nodeType":"49","messageId":"50","endLine":3,"endColumn":68},{"ruleId":"47","severity":1,"message":"67","line":3,"column":70,"nodeType":"49","messageId":"50","endLine":3,"endColumn":78},{"ruleId":"47","severity":1,"message":"68","line":13,"column":10,"nodeType":"49","messageId":"50","endLine":13,"endColumn":15},{"ruleId":"47","severity":1,"message":"69","line":13,"column":17,"nodeType":"49","messageId":"50","endLine":13,"endColumn":25},{"ruleId":"54","severity":1,"message":"70","line":32,"column":6,"nodeType":"56","endLine":32,"endColumn":8,"suggestions":"71"},{"ruleId":"47","severity":1,"message":"72","line":1,"column":17,"nodeType":"49","messageId":"50","endLine":1,"endColumn":26},{"ruleId":"47","severity":1,"message":"73","line":2,"column":10,"nodeType":"49","messageId":"50","endLine":2,"endColumn":14},{"ruleId":"47","severity":1,"message":"74","line":4,"column":64,"nodeType":"49","messageId":"50","endLine":4,"endColumn":75},"no-unused-vars","'Redirect' is defined but never used.","Identifier","unusedVar","'mobile' is assigned a value but never used.","'place' is assigned a value but never used.","'imgUrl' is assigned a value but never used.","react-hooks/exhaustive-deps","React Hook useEffect has missing dependencies: 'getAssociation', 'getImg', 'getPlace', 'props.history', and 'search'. Either include them or remove the dependency array.","ArrayExpression",["75"],"'places' is assigned a value but never used.","react/jsx-no-duplicate-props","No duplicate props allowed","JSXAttribute","'axios' is defined but never used.","'Col' is defined but never used.","'Badge' is defined but never used.","'Card' is defined but never used.","'Accordion' is defined but never used.","'Carousel' is defined but never used.","'state' is assigned a value but never used.","'setState' is assigned a value but never used.","React Hook useEffect has missing dependencies: 'getReview' and 'infiniteScroll'. Either include them or remove the dependency array.",["76"],"'useEffect' is defined but never used.","'Link' is defined but never used.","'FormControl' is defined but never used.",{"desc":"77","fix":"78"},{"desc":"79","fix":"80"},"Update the dependencies array to be: [getAssociation, getImg, getPlace, props.history, search, state]",{"range":"81","text":"82"},"Update the dependencies array to be: [getReview, infiniteScroll]",{"range":"83","text":"84"},[2633,2640],"[getAssociation, getImg, getPlace, props.history, search, state]",[962,964],"[getReview, infiniteScroll]"]
\ No newline at end of file
[{"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\reportWebVitals.js":"1","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\Search.js":"2","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\index.js":"3","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Components\\Place.js":"4","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Components\\Paginations.js":"5","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\App.js":"6"},{"size":362,"mtime":1608689675665,"results":"7","hashOfConfig":"8"},{"size":7987,"mtime":1611670471858,"results":"9","hashOfConfig":"8"},{"size":889,"mtime":1611497488080,"results":"10","hashOfConfig":"8"},{"size":2548,"mtime":1611668355580,"results":"11","hashOfConfig":"8"},{"size":2199,"mtime":1610325754517,"results":"12","hashOfConfig":"8"},{"size":1456,"mtime":1611495914736,"results":"13","hashOfConfig":"8"},{"filePath":"14","messages":"15","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1n20xnc",{"filePath":"16","messages":"17","errorCount":0,"warningCount":6,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"18","messages":"19","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":"20"},{"filePath":"21","messages":"22","errorCount":0,"warningCount":8,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"23","messages":"24","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"25","messages":"26","errorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\reportWebVitals.js",[],"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\Search.js",["27","28","29","30","31","32"],"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\index.js",["33","34"],"import React from 'react';\r\nimport ReactDOM from 'react-dom';\r\nimport './index.css';\r\nimport 'bootstrap/dist/css/bootstrap.min.css';\r\nimport App from './Pages/App';\r\nimport Search from './Pages/Search';\r\nimport axios from 'axios';\r\nimport reportWebVitals from './reportWebVitals';\r\nimport {\r\n BrowserRouter as Router,\r\n Switch,\r\n Route,\r\n Redirect,\r\n} from \"react-router-dom\";\r\n\r\nReactDOM.render(\r\n <React.StrictMode>\r\n <Router>\r\n <Switch>\r\n <Route exact path=\"/\" component={App} />\r\n <Route path=\"/search\" component={Search} />\r\n </Switch>\r\n </Router>\r\n </React.StrictMode>,\r\n document.getElementById('root')\r\n);\r\n\r\n// If you want to start measuring performance in your app, pass a function\r\n// to log results (for example: reportWebVitals(console.log))\r\n// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals\r\nreportWebVitals();\r\n","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Components\\Place.js",["35","36","37","38","39","40","41","42"],"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Components\\Paginations.js",[],"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\App.js",["43","44","45"],{"ruleId":"46","severity":1,"message":"47","line":2,"column":16,"nodeType":"48","messageId":"49","endLine":2,"endColumn":24},{"ruleId":"50","severity":1,"message":"51","line":34,"column":8,"nodeType":"52","endLine":34,"endColumn":10,"suggestions":"53"},{"ruleId":"50","severity":1,"message":"54","line":38,"column":8,"nodeType":"52","endLine":38,"endColumn":21,"suggestions":"55"},{"ruleId":"50","severity":1,"message":"56","line":53,"column":8,"nodeType":"52","endLine":53,"endColumn":10,"suggestions":"57"},{"ruleId":"46","severity":1,"message":"58","line":68,"column":11,"nodeType":"48","messageId":"49","endLine":68,"endColumn":17},{"ruleId":"59","severity":1,"message":"60","line":129,"column":35,"nodeType":"61","endLine":129,"endColumn":76},{"ruleId":"46","severity":1,"message":"62","line":7,"column":8,"nodeType":"48","messageId":"49","endLine":7,"endColumn":13},{"ruleId":"46","severity":1,"message":"47","line":13,"column":3,"nodeType":"48","messageId":"49","endLine":13,"endColumn":11},{"ruleId":"46","severity":1,"message":"63","line":3,"column":33,"nodeType":"48","messageId":"49","endLine":3,"endColumn":36},{"ruleId":"46","severity":1,"message":"64","line":3,"column":46,"nodeType":"48","messageId":"49","endLine":3,"endColumn":51},{"ruleId":"46","severity":1,"message":"65","line":3,"column":53,"nodeType":"48","messageId":"49","endLine":3,"endColumn":57},{"ruleId":"46","severity":1,"message":"66","line":3,"column":59,"nodeType":"48","messageId":"49","endLine":3,"endColumn":68},{"ruleId":"46","severity":1,"message":"67","line":3,"column":70,"nodeType":"48","messageId":"49","endLine":3,"endColumn":78},{"ruleId":"46","severity":1,"message":"68","line":13,"column":10,"nodeType":"48","messageId":"49","endLine":13,"endColumn":15},{"ruleId":"46","severity":1,"message":"69","line":13,"column":17,"nodeType":"48","messageId":"49","endLine":13,"endColumn":25},{"ruleId":"50","severity":1,"message":"70","line":32,"column":6,"nodeType":"52","endLine":32,"endColumn":8,"suggestions":"71"},{"ruleId":"46","severity":1,"message":"72","line":1,"column":17,"nodeType":"48","messageId":"49","endLine":1,"endColumn":26},{"ruleId":"46","severity":1,"message":"73","line":2,"column":10,"nodeType":"48","messageId":"49","endLine":2,"endColumn":14},{"ruleId":"46","severity":1,"message":"74","line":4,"column":64,"nodeType":"48","messageId":"49","endLine":4,"endColumn":75},"no-unused-vars","'Redirect' is defined but never used.","Identifier","unusedVar","react-hooks/exhaustive-deps","React Hook useEffect has a missing dependency: 'getAssociation'. Either include it or remove the dependency array.","ArrayExpression",["75"],"React Hook useEffect has a missing dependency: 'index'. Either include it or remove the dependency array. You can also replace multiple useState variables with useReducer if 'setPagePlace' needs the current value of 'index'.",["76"],"React Hook useEffect has missing dependencies: 'getAssociation', 'props.history', 'search', and 'state'. Either include them or remove the dependency array.",["77"],"'places' is assigned a value but never used.","react/jsx-no-duplicate-props","No duplicate props allowed","JSXAttribute","'axios' is defined but never used.","'Col' is defined but never used.","'Badge' is defined but never used.","'Card' is defined but never used.","'Accordion' is defined but never used.","'Carousel' is defined but never used.","'state' is assigned a value but never used.","'setState' is assigned a value but never used.","React Hook useEffect has missing dependencies: 'getReview' and 'infiniteScroll'. Either include them or remove the dependency array.",["78"],"'useEffect' is defined but never used.","'Link' is defined but never used.","'FormControl' is defined but never used.",{"desc":"79","fix":"80"},{"desc":"81","fix":"82"},{"desc":"83","fix":"84"},{"desc":"85","fix":"86"},"Update the dependencies array to be: [getAssociation]",{"range":"87","text":"88"},"Update the dependencies array to be: [association, index]",{"range":"89","text":"90"},"Update the dependencies array to be: [getAssociation, props.history, search, state]",{"range":"91","text":"92"},"Update the dependencies array to be: [getReview, infiniteScroll]",{"range":"93","text":"94"},[1288,1290],"[getAssociation]",[1398,1411],"[association, index]",[1994,1996],"[getAssociation, props.history, search, state]",[962,964],"[getReview, infiniteScroll]"]
\ No newline at end of file
import axios from 'axios';
import React, { useEffect, useState } from 'react';
import { Modal, Container, Row, Col, Button, Badge, Card, Accordion, Carousel } from 'react-bootstrap';
import { Modal, Container, Row, Button, } from 'react-bootstrap';
function Place(props) {
const [reviews, setReviews] = useState()
......@@ -27,8 +27,6 @@ function Place(props) {
size="xl"
keyboard="true"
variant="backdrop.in"
// show={lgShow}
// onHide={() => setLgShow(false)}
aria-labelledby="example-modal-sizes-title-lg">
<Modal.Header closeButton>
<Modal.Title id="contained-modal-title-vcenter" style={{ fontSize: '40px' }}>
......
import React, { useEffect, useState } from 'react';
import { Link, Redirect } from 'react-router-dom';
import React, { useState } from 'react';
import { Redirect } from 'react-router-dom';
import ohuh from '../ohuh.PNG';
import { Container, Row, Form, Image, InputGroup, Button, Col, FormControl } from 'react-bootstrap';
import { Container, Row, Form, Image, InputGroup, Button, Col } from 'react-bootstrap';
function App() {
const [state, setState] = useState(false);
......
......@@ -5,7 +5,7 @@ import Place from '../Components/Place';
import { Container, Form, Row, Col, Card, Image, InputGroup, FormControl, Button } from 'react-bootstrap';
import Paginations from '../Components/Paginations';
import axios from 'axios';
import queryString from 'query-string'
import queryString from 'query-string' // react route dom 에 있다. 확인해보기
function Search(props) {
const endPage = 10;
......@@ -13,31 +13,8 @@ function Search(props) {
const [index, setIndex] = useState(1);
const [showSet, setShowSet] = useState([false, false, false, false]);
const [search, setSearch] = useState(queryString.parse(props.location.search).keyword);
const [mobile, setMobile] = useState();
const [place, setPlace] = useState([{ name: "", category: "", address: "" }])
const [imgUrl, setImgUrl] = useState([])
const [pagePlace, setPagePlace] = useState();
const [association, setAssociation] = useState([])
const getImg = () => {
axios.get(`/api/search/imges?keyword=${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?keyword=${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?keyword=${search}`)
......@@ -53,18 +30,15 @@ function Search(props) {
useEffect(() => {
getPlace()
getImg()
getAssociation()
getPlace()
getImg()
}, []);
if (window.innerWidth < 960) {
setMobile(true)
} else {
setMobile(false)
}
useEffect(() => {
setPagePlace(paginate(association, index, association.length))
}, [association]);
useEffect(() => {
getAssociation()
if (state) {
// window.location.reload()
// return <Redirect to={{
......@@ -74,8 +48,21 @@ function Search(props) {
props.history.push('/search?keyword=' + search)
// setState(false)
// console.log("search야", search)
} window.addEventListener("scroll", infiniteScroll);
return () => { window.removeEventListener("scroll", infiniteScroll); }
}, []);
const infiniteScroll = () => {
const { documentElement, body } = document;
const scrollHeight = Math.max(documentElement.scrollHeight, body.scrollHeight);
const scrollTop = Math.max(documentElement.scrollTop, body.scrollTop);
const clientHeight = documentElement.clientHeight;
if (scrollTop + clientHeight >= scrollHeight) {
// getReview();
console.log("더불러")
}
}, [state]);
console.log(scrollHeight, scrollTop, clientHeight)
}
const places = [{
......@@ -134,8 +121,6 @@ function Search(props) {
return page
}
const pagePlace = paginate(association, index, association.length)
let time = new Date()
return (
......@@ -157,7 +142,6 @@ function Search(props) {
</InputGroup>
</Form>
</Row>
{time.toLocaleString()}
<Row className="d-flex flex-wrap">
{pagePlace.map((place, index) => {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -3,90 +3,120 @@ import cheerio from 'cheerio'
import fs from 'fs'
import axios from 'axios';
const searchPlace = async (req, res) => {
const searchPlace = async (req, res, next,) => {
let DuplicateCheckPlace = await Places.findOne({ name: req.query.keyword })
req.places = DuplicateCheckPlace
if (DuplicateCheckPlace) {
res.send(DuplicateCheckPlace)
console.log("11111111111111111111111Place################ 기존플레이스줄력중")
}
else {
console.log("2222222222222222222222222222222222222222222222222222222")
const url = "https://search.naver.com/search.naver?sm=tab_hty.top&where=nexearch&query=" + encodeURI(req.query.keyword)
const editUrl = /(http(s)?:\/\/)([a-z0-9\w]+\.*)+[a-z0-9]{2,4}/gi
axios.get(url)
.then(async (response) => {
const html = response.data
// fs.writeFileSync("googleReview", html, { encoding: 'utf-8' })
let $1 = cheerio.load(html);
let places = {}
$1('.ct_box_area').each(function (i) {
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 { data: html } = await axios.get(url)
let $1 = cheerio.load(html);
let places = {}
$1('.ct_box_area').each(function (i) {
places = {
name: $1('.biz_name').text(), category: $1('.category').text(), address: $1('.addr').text(),
img: "https://t1.daumcdn.net/thumb/R600x0/?fname=http%3A%2F%2Ft1.daumcdn.net%2Fqna%2Fimage%2F4b035cdf8372d67108f7e8d339660479dfb41bbd",
times: []
}
})
req.places = places
}
next()
}
const searchImg = async (req, res) => {
let DuplicateCheckImg = await Places.findOne({ name: req.query.keyword })
if (DuplicateCheckImg) {
if (DuplicateCheckImg.img !== "https://t1.daumcdn.net/thumb/R600x0/?fname=http%3A%2F%2Ft1.daumcdn.net%2Fqna%2Fimage%2F4b035cdf8372d67108f7e8d339660479dfb41bbd") {
res.send(DuplicateCheckImg)
console.log("333333333333333333333333333IMG@@@@@@@@@@@@@@@@@@@ 기존이미지줄력중")
}
else if (DuplicateCheckImg.img === "https://t1.daumcdn.net/thumb/R600x0/?fname=http%3A%2F%2Ft1.daumcdn.net%2Fqna%2Fimage%2F4b035cdf8372d67108f7e8d339660479dfb41bbd") {
console.log("4444444444444444444444444444444444444444444444444")
const imgUrl = "https://www.google.com/search?q=" + encodeURI(req.query.keyword) + "+site:tistory.com/&sxsrf=ALeKk023Dv08KQDodRmpB5222lQuzw2Vaw:1610612821100&source=lnms&tbm=isch"
axios.get(imgUrl)
.then(async (response) => {
const html = response.data
let name = req.query.keyword
let $1 = cheerio.load(html);
let images = $1('.RAyV4b').find('img').attr('src')
const searchImg = async (req, res, next) => {
//사진만 업데이트
let Place = await Places.findOne({ name: req.query.keyword })
Place.times.push(new Date().toLocaleString())
await Places.updateOne({ name: req.query.keyword }, { img: images, times: Place.times })
console.log("d213532513212osfnlagm2214124", req.places)
res.send(images)
})
if (req.places.img !== "https://t1.daumcdn.net/thumb/R600x0/?fname=http%3A%2F%2Ft1.daumcdn.net%2Fqna%2Fimage%2F4b035cdf8372d67108f7e8d339660479dfb41bbd") {
console.log("333333333333333333333333333IMG@@@@@@@@@@@@@@@@@@@ 기존이미지줄력중")
req.places.times.push(new Date().toLocaleString())
console.log("세이브 전 111111111111111111", req.places)
const newPlaces = await new Places(req.places).save()
next()
} else if (req.places.img === "https://t1.daumcdn.net/thumb/R600x0/?fname=http%3A%2F%2Ft1.daumcdn.net%2Fqna%2Fimage%2F4b035cdf8372d67108f7e8d339660479dfb41bbd") {
const imgUrl = "https://www.google.com/search?q=" + encodeURI(req.query.keyword) + "+site:tistory.com/&sxsrf=ALeKk023Dv08KQDodRmpB5222lQuzw2Vaw:1610612821100&source=lnms&tbm=isch"
} else {
console.log("IMG에러")
}
axios.get(imgUrl)
.then(async (response) => {
console.log("4444444444444444444444444444444444444444444444444새로운 이미지 출력중")
const html = response.data
let name = req.query.keyword
let $1 = cheerio.load(html);
let images = $1('.RAyV4b').find('img').attr('src')
req.places.img = images
console.log("4141414141414141", req.places)
//사진만 업데이트
// let Place2 = await Places.findOne({ name: req.query.keyword })
req.places.times.push(new Date().toLocaleString())
// await Places.updateOne({ name: req.query.keyword }, { img: images, times: Place2.times })
// res.send(images)
console.log("세이브 전 222222222222222", req.places)
const newPlaces = await new Places(req.places).save()
next()
})
} else {
console.log("이미지 생성 오류발생!!")
}
}
// if (DuplicateCheckImg !== "https://t1.daumcdn.net/thumb/R600x0/?fname=http%3A%2F%2Ft1.daumcdn.net%2Fqna%2Fimage%2F4b035cdf8372d67108f7e8d339660479dfb41bbd") {
// console.log("333333333333333333333333333IMG@@@@@@@@@@@@@@@@@@@ 기존이미지줄력중")
// }
// else if (DuplicateCheckImg === "https://t1.daumcdn.net/thumb/R600x0/?fname=http%3A%2F%2Ft1.daumcdn.net%2Fqna%2Fimage%2F4b035cdf8372d67108f7e8d339660479dfb41bbd") {
// console.log("4444444444444444444444444444444444444444444444444")
// const imgUrl = "https://www.google.com/search?q=" + encodeURI(req.query.keyword) + "+site:tistory.com/&sxsrf=ALeKk023Dv08KQDodRmpB5222lQuzw2Vaw:1610612821100&source=lnms&tbm=isch"
// axios.get(imgUrl)
// .then(async (response) => {
// const html = response.data
// let name = req.query.keyword
// let $1 = cheerio.load(html);
// let images = $1('.RAyV4b').find('img').attr('src')
// req.places.img = images
// //사진만 업데이트
// // let Place2 = await Places.findOne({ name: req.query.keyword })
// req.places.times.push(new Date().toLocaleString())
// // await Places.updateOne({ name: req.query.keyword }, { img: images, times: Place2.times })
// // res.send(images)
// console.log("세이브 전 111111111111111111", req.places)
// const newPlaces = await new Places(req.places).save()
// next()
// })
// } else {
// console.log("IMG에러")
// }
// req.places.times.push(new Date().toLocaleString())
// console.log("세이브 전222222222222222222222")
// next()
// }
//맨 처음 검색하는 지역의 관광지의 경우 association을 받아올 수 없다.
const searchAssociation = async (req, res) => {
let Place = await Places.findOne({ name: req.query.keyword })
// let Place3 = await Places.findOne({ name: req.query.keyword })
let Place3 = req.places.address
// if (!Place) {
// res.send([])
// }
if (!Place) {
res.status(404).send({ error: "Place.address is null" })
if (!Place3) {
console.log("asdfasdfasdf222222222222222222dsaf2222222222214123q5", Place3)
res.send({ error: "Place.address is null" })
}
else {
let addresse = Place.address.split(' ')[0]
let addresse = Place3.split(' ')[0]
let AssociationsId = []
let addressPlaces = new RegExp(`${addresse}`)
console.log("여기보세요", addressPlaces)
let responsePlaces = await Places.find({ address: addressPlaces })
let responsePlaces = await Places.find({ address: addressPlaces }).sort({ updatedAt: -1 })
//몽구스나 몽고디비에 있는 sort 확인해보고 나열하기.
console.log("$$$$$$$$$$$4", responsePlaces)
res.send(responsePlaces)
}
// responsePlaces.map(Association => {
......
......@@ -70,4 +70,4 @@ const find = (req, res, next) => {
next()
})
}
export default { search, find }
\ No newline at end of file
export default { search, find }
......@@ -3,13 +3,14 @@ import place from '../controllers/place.controller.js'
const router = express.Router()
router.route('/api/search/imges')
.get(place.searchImg)
// router.route('/api/search/places')
// .get(place.searchPlace, place.searchImg, place.searchAssociation)
// router.route('/api/search/imges')
// .get(place.searchImg)
router.route('/api/search/places')
.get(place.searchPlace)
router.route('/api/search/association')
.get(place.searchAssociation)
.get(place.searchPlace, place.searchImg, place.searchAssociation)
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