Commit 609d4441 authored by baesangjune's avatar baesangjune
Browse files

DB확인절차

parent 768b5382
[{"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"},{"size":362,"mtime":1608689675665,"results":"5","hashOfConfig":"6"},{"size":9422,"mtime":1611064279531,"results":"7","hashOfConfig":"6"},{"size":1004,"mtime":1610344592277,"results":"8","hashOfConfig":"6"},{"size":5415,"mtime":1610615925584,"results":"9","hashOfConfig":"6"},{"filePath":"10","messages":"11","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1n20xnc",{"filePath":"12","messages":"13","errorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"14","messages":"15","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"16","messages":"17","errorCount":0,"warningCount":6,"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",["18","19","20"],"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\index.js",[],"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Components\\Place.js",["21","22","23","24","25","26"],{"ruleId":"27","severity":1,"message":"28","line":5,"column":83,"nodeType":"29","messageId":"30","endLine":5,"endColumn":93},{"ruleId":"27","severity":1,"message":"31","line":14,"column":12,"nodeType":"29","messageId":"30","endLine":14,"endColumn":18},{"ruleId":"32","severity":1,"message":"33","line":81,"column":35,"nodeType":"34","endLine":81,"endColumn":76},{"ruleId":"27","severity":1,"message":"35","line":3,"column":33,"nodeType":"29","messageId":"30","endLine":3,"endColumn":36},{"ruleId":"27","severity":1,"message":"36","line":3,"column":46,"nodeType":"29","messageId":"30","endLine":3,"endColumn":51},{"ruleId":"27","severity":1,"message":"37","line":3,"column":53,"nodeType":"29","messageId":"30","endLine":3,"endColumn":57},{"ruleId":"27","severity":1,"message":"38","line":3,"column":59,"nodeType":"29","messageId":"30","endLine":3,"endColumn":68},{"ruleId":"27","severity":1,"message":"39","line":3,"column":70,"nodeType":"29","messageId":"30","endLine":3,"endColumn":78},{"ruleId":"40","severity":1,"message":"41","line":20,"column":6,"nodeType":"42","endLine":20,"endColumn":8,"suggestions":"43"},"no-unused-vars","'Pagination' is defined but never used.","Identifier","unusedVar","'mobile' is assigned a value but never used.","react/jsx-no-duplicate-props","No duplicate props allowed","JSXAttribute","'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.","react-hooks/exhaustive-deps","React Hook useEffect has a missing dependency: 'getReview'. Either include it or remove the dependency array.","ArrayExpression",["44"],{"desc":"45","fix":"46"},"Update the dependencies array to be: [getReview]",{"range":"47","text":"48"},[560,562],"[getReview]"] [{"C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\index.js":"1","C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\reportWebVitals.js":"2","C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\Components\\Place.js":"3","C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\Components\\Paginations.js":"4","C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\Pages\\Search.js":"5"},{"size":1040,"mtime":1611254909400,"results":"6","hashOfConfig":"7"},{"size":375,"mtime":1611254909401,"results":"8","hashOfConfig":"7"},{"size":1551,"mtime":1611256661135,"results":"9","hashOfConfig":"7"},{"size":2199,"mtime":1611254909395,"results":"10","hashOfConfig":"7"},{"size":7353,"mtime":1611259355418,"results":"11","hashOfConfig":"7"},{"filePath":"12","messages":"13","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"13y9yvi",{"filePath":"14","messages":"15","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"16","messages":"17","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"18","messages":"19","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"20","messages":"21","errorCount":0,"warningCount":6,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\index.js",[],"C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\reportWebVitals.js",[],"C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\Components\\Place.js",["22"],"C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\Components\\Paginations.js",[],"C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\Pages\\Search.js",["23","24","25","26","27","28"],{"ruleId":"29","severity":1,"message":"30","line":20,"column":6,"nodeType":"31","endLine":20,"endColumn":8,"suggestions":"32"},{"ruleId":"33","severity":1,"message":"34","line":15,"column":12,"nodeType":"35","messageId":"36","endLine":15,"endColumn":18},{"ruleId":"33","severity":1,"message":"37","line":16,"column":12,"nodeType":"35","messageId":"36","endLine":16,"endColumn":17},{"ruleId":"33","severity":1,"message":"38","line":17,"column":12,"nodeType":"35","messageId":"36","endLine":17,"endColumn":18},{"ruleId":"29","severity":1,"message":"39","line":64,"column":8,"nodeType":"31","endLine":64,"endColumn":10,"suggestions":"40"},{"ruleId":"33","severity":1,"message":"41","line":71,"column":11,"nodeType":"35","messageId":"36","endLine":71,"endColumn":17},{"ruleId":"42","severity":1,"message":"43","line":129,"column":35,"nodeType":"44","endLine":129,"endColumn":76},"react-hooks/exhaustive-deps","React Hook useEffect has a missing dependency: 'getReview'. Either include it or remove the dependency array.","ArrayExpression",["45"],"no-unused-vars","'mobile' is assigned a value but never used.","Identifier","unusedVar","'place' is assigned a value but never used.","'imgUrl' is assigned a value but never used.","React Hook useEffect has missing dependencies: 'getAssociation', 'getImg', and 'getPlace'. Either include them or remove the dependency array.",["46"],"'places' is assigned a value but never used.","react/jsx-no-duplicate-props","No duplicate props allowed","JSXAttribute",{"desc":"47","fix":"48"},{"desc":"49","fix":"50"},"Update the dependencies array to be: [getReview]",{"range":"51","text":"52"},"Update the dependencies array to be: [getAssociation, getImg, getPlace]",{"range":"53","text":"54"},[571,573],"[getReview]",[2084,2086],"[getAssociation, getImg, getPlace]"]
\ No newline at end of file \ No newline at end of file
...@@ -38,5 +38,5 @@ ...@@ -38,5 +38,5 @@
"last 1 safari version" "last 1 safari version"
] ]
}, },
"proxy":"http://localhost:3001" "proxy": "http://localhost:3001"
} }
import axios from 'axios'; import axios from 'axios';
import React, { useEffect, useState } from 'react'; 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) { function Place(props) {
const [reviews, setReviews] = useState([]) const [reviews, setReviews] = useState([{ title: "", link: "", summery: "", content: "" }])
const getReview = () => { const getReview = () => {
axios.get(`/api/review/${props.search.name}`) axios.get(`/api/review/${props.search.name}`)
.then(res => { .then(res => {
...@@ -24,8 +24,6 @@ function Place(props) { ...@@ -24,8 +24,6 @@ function Place(props) {
size="xl" size="xl"
keyboard="true" keyboard="true"
variant="backdrop.in" variant="backdrop.in"
// show={lgShow}
// onHide={() => setLgShow(false)}
aria-labelledby="example-modal-sizes-title-lg"> aria-labelledby="example-modal-sizes-title-lg">
<Modal.Header closeButton> <Modal.Header closeButton>
<Modal.Title id="contained-modal-title-vcenter" style={{ fontSize: '40px' }}> <Modal.Title id="contained-modal-title-vcenter" style={{ fontSize: '40px' }}>
......
import React, { useEffect, useState } from 'react'; import React, { useState } from 'react';
import { Link, Redirect } from 'react-router-dom'; import { Redirect } from 'react-router-dom';
import ohuh from '../ohuh.PNG'; 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() { function App() {
const [state, setState] = useState(false); const [state, setState] = useState(false);
......
...@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react'; ...@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
import { Link, Redirect } from 'react-router-dom'; import { Link, Redirect } from 'react-router-dom';
import ohuh from '../ohuh-sm.PNG'; 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} from 'react-bootstrap';
import Paginations from '../Components/Paginations'; import Paginations from '../Components/Paginations';
import axios from 'axios'; import axios from 'axios';
...@@ -121,14 +121,6 @@ function Search(props) { ...@@ -121,14 +121,6 @@ function Search(props) {
const pagePlace = paginate(association, index, association.length) 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() let time = new Date()
return ( return (
...@@ -150,28 +142,7 @@ function Search(props) { ...@@ -150,28 +142,7 @@ function Search(props) {
</InputGroup> </InputGroup>
</Form> </Form>
</Row> </Row>
{/* {time.toString()}**** */} {time.toLocaleString()}
{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 (
...@@ -194,8 +165,6 @@ function Search(props) { ...@@ -194,8 +165,6 @@ function Search(props) {
) )
})} })}
</Row> </Row>
{/* {console.log(showSet)} */}
{/* 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>
......
This diff is collapsed.
...@@ -2,29 +2,27 @@ import Places from '../models/Place.js' ...@@ -2,29 +2,27 @@ import Places from '../models/Place.js'
import cheerio from 'cheerio' import cheerio from 'cheerio'
import fs from 'fs' import fs from 'fs'
import axios from 'axios'; import axios from 'axios';
import { time } from 'console';
const searchPlace = async (req, res) => { const searchPlace = async (req, res) => {
let DuplicateCheckPlace = await Places.findOne({ name: req.params.search })
if (DuplicateCheckPlace) {
res.send(DuplicateCheckPlace)
onsole.log("11111111111111111111111Place################ 기존플레이스줄력중")
}
else {
console.log("2222222222222222222222222222222222222222222222222222222")
const url = "https://search.naver.com/search.naver?sm=tab_hty.top&where=nexearch&query=" + encodeURI(req.params.search) const url = "https://search.naver.com/search.naver?sm=tab_hty.top&where=nexearch&query=" + encodeURI(req.params.search)
const editUrl = /(http(s)?:\/\/)([a-z0-9\w]+\.*)+[a-z0-9]{2,4}/gi const editUrl = /(http(s)?:\/\/)([a-z0-9\w]+\.*)+[a-z0-9]{2,4}/gi
axios.get(url) axios.get(url)
.then(async (response) => { .then(async (response) => {
const html = response.data const html = response.data
// console.log(html)
fs.writeFileSync("googleReview", html, { encoding: 'utf-8' }) fs.writeFileSync("googleReview", html, { encoding: 'utf-8' })
let $1 = cheerio.load(html); let $1 = cheerio.load(html);
let places = {} let places = {}
$1('.ct_box_area').each(function (i) { $1('.ct_box_area').each(function (i) {
// console.log($1('.biz_name').text())
// 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() } places[i] = { name: $1('.biz_name').text(), category: $1('.category').text(), address: $1('.addr').text() }
}) })
// 값이 비어있거나 에러가 생겼을 때를 대비해 try catch를 해야함 // 값이 비어있거나 에러가 생겼을 때를 대비해 try catch를 해야함
...@@ -32,9 +30,20 @@ const searchPlace = async (req, res) => { ...@@ -32,9 +30,20 @@ const searchPlace = async (req, res) => {
).save() ).save()
res.send(places) res.send(places)
}) })
}
} }
const searchImg = async (req, res) => { const searchImg = async (req, res) => {
let DuplicateCheckImg = await Places.findOne({ name: req.params.search })
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.params.search) + "+site:tistory.com/&sxsrf=ALeKk023Dv08KQDodRmpB5222lQuzw2Vaw:1610612821100&source=lnms&tbm=isch" const imgUrl = "https://www.google.com/search?q=" + encodeURI(req.params.search) + "+site:tistory.com/&sxsrf=ALeKk023Dv08KQDodRmpB5222lQuzw2Vaw:1610612821100&source=lnms&tbm=isch"
axios.get(imgUrl) axios.get(imgUrl)
...@@ -45,15 +54,6 @@ const searchImg = async (req, res) => { ...@@ -45,15 +54,6 @@ const searchImg = async (req, res) => {
let images = $1('.RAyV4b').find('img').attr('src') let images = $1('.RAyV4b').find('img').attr('src')
// let images = []
// $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 }) let Place = await Places.findOne({ name: req.params.search })
Place.times.push(new Date().toLocaleString()) Place.times.push(new Date().toLocaleString())
...@@ -65,6 +65,12 @@ const searchImg = async (req, res) => { ...@@ -65,6 +65,12 @@ const searchImg = async (req, res) => {
res.send(images) res.send(images)
}) })
} else {
console.log("IMG에러")
}
} }
const searchAssociation = async (req, res) => { const searchAssociation = async (req, res) => {
......
import Review from '../models/Review.js' import Review from '../models/Review.js'
import cheerio from "cheerio"; import cheerio from "cheerio";
import iconv from 'iconv'
import fs from 'fs' import fs from 'fs'
import axios from 'axios'; import axios from 'axios';
const Iconv = iconv.Iconv
const search = async (req, res, next) => { const search = async (req, res, next) => {
try { try {
let reviews = [] let reviews = []
let content = [] let content = []
Review.find() // Review.find()
const url = "https://www.google.com/search?q=" + encodeURI(req.params.search) + "+site%3Atistory.com&page_no=1" const url = "https://www.google.com/search?q=" + encodeURI(req.params.search) + "+site%3Atistory.com&page_no=1"
const response1 = await axios.get(url) const response1 = await axios.get(url)
// console.log(response1.data) // console.log(response1.data)
...@@ -36,8 +34,8 @@ const search = async (req, res, next) => { ...@@ -36,8 +34,8 @@ const search = async (req, res, next) => {
res.send(reviews) res.send(reviews)
} catch (error) { } catch (error) {
console.log(error) // console.log(error)
res.send(error) // res.send(error)
} }
} }
...@@ -71,8 +69,4 @@ const getReview = async (link) => { ...@@ -71,8 +69,4 @@ const getReview = async (link) => {
} }
} }
const find = (res,req,next) => { export default { search }
Review.find({address: }) \ No newline at end of file
}
export default { search, find }
\ 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