Commit 05f1c0e5 authored by baesangjune's avatar baesangjune
Browse files

.

parent 0dfdacbe
[{"C:\\Users\\Korea\\Desktop\\2020winter\\search-page\\client\\src\\index.js":"1","C:\\Users\\Korea\\Desktop\\2020winter\\search-page\\client\\src\\reportWebVitals.js":"2","C:\\Users\\Korea\\Desktop\\2020winter\\search-page\\client\\src\\Components\\Paginations.js":"3","C:\\Users\\Korea\\Desktop\\2020winter\\search-page\\client\\src\\Components\\Place.js":"4","C:\\Users\\Korea\\Desktop\\2020winter\\search-page\\client\\src\\Pages\\App.js":"5","C:\\Users\\Korea\\Desktop\\2020winter\\search-page\\client\\src\\Pages\\Search.js":"6"},{"size":1133,"mtime":1610350393004,"results":"7","hashOfConfig":"8"},{"size":375,"mtime":1609072355927,"results":"9","hashOfConfig":"8"},{"size":2199,"mtime":1610343833899,"results":"10","hashOfConfig":"8"},{"size":5363,"mtime":1610610376162,"results":"11","hashOfConfig":"8"},{"size":1553,"mtime":1610514553145,"results":"12","hashOfConfig":"8"},{"size":38694,"mtime":1610610579948,"results":"13","hashOfConfig":"8"},{"filePath":"14","messages":"15","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"16"},"zqc0qw",{"filePath":"17","messages":"18","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"16"},{"filePath":"19","messages":"20","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"16"},{"filePath":"21","messages":"22","errorCount":0,"warningCount":6,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"23","messages":"24","errorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":"25","usedDeprecatedRules":"16"},{"filePath":"26","messages":"27","errorCount":0,"warningCount":5,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"C:\\Users\\Korea\\Desktop\\2020winter\\search-page\\client\\src\\index.js",[],["28","29"],"C:\\Users\\Korea\\Desktop\\2020winter\\search-page\\client\\src\\reportWebVitals.js",[],"C:\\Users\\Korea\\Desktop\\2020winter\\search-page\\client\\src\\Components\\Paginations.js",[],"C:\\Users\\Korea\\Desktop\\2020winter\\search-page\\client\\src\\Components\\Place.js",["30","31","32","33","34","35"],"C:\\Users\\Korea\\Desktop\\2020winter\\search-page\\client\\src\\Pages\\App.js",["36","37","38"],"import React, { useEffect, useState } from 'react';\r\nimport { Link, Redirect } from 'react-router-dom';\r\nimport ohuh from '../ohuh.PNG';\r\nimport { Container, Row, Form, Image, InputGroup, Button, Col, FormControl } from 'react-bootstrap';\r\n\r\nfunction App() {\r\n const [state, setState] = useState(false);\r\n const [search, setSearch] = useState(\"\");\r\n\r\n if (state !== false) {\r\n return <Redirect to={{\r\n pathname: `/search/${search}`,\r\n state: { id: search },\r\n }} />;\r\n }\r\n\r\n const handleChange = (e) => {\r\n setSearch(e.target.value);\r\n }\r\n\r\n const handleSubmit = () => {\r\n setState(true);\r\n }\r\n\r\n return (\r\n <Container className=\"vh-100 d-flex justify-content-md-center align-items-center\">\r\n <Col md={6} lassName=\" d-flex justify-content-center\">\r\n <Row style={{marginBottom:20}}>\r\n <Image src={ohuh} />\r\n </Row>\r\n <Row style={{marginBottom:500}}>\r\n <Form className=\"vw-100\" onSubmit={handleSubmit}>\r\n <InputGroup>\r\n <Form.Control\r\n size=\"lg\"\r\n placeholder=\"검색어를 입력하세요.\"\r\n aria-label=\"Large\"\r\n aria-describedby=\"inputGroup-sizing-sm\"\r\n onChange={handleChange}\r\n />\r\n <InputGroup.Append>\r\n <Button type='submit' variant=\"outline-secondary\">검색</Button>\r\n </InputGroup.Append>\r\n </InputGroup>\r\n </Form>\r\n </Row>\r\n </Col>\r\n </Container>\r\n );\r\n}\r\n\r\nexport default App;","C:\\Users\\Korea\\Desktop\\2020winter\\search-page\\client\\src\\Pages\\Search.js",["39","40","41","42","43"],{"ruleId":"44","replacedBy":"45"},{"ruleId":"46","replacedBy":"47"},{"ruleId":"48","severity":1,"message":"49","line":3,"column":33,"nodeType":"50","messageId":"51","endLine":3,"endColumn":36},{"ruleId":"48","severity":1,"message":"52","line":3,"column":46,"nodeType":"50","messageId":"51","endLine":3,"endColumn":51},{"ruleId":"48","severity":1,"message":"53","line":3,"column":53,"nodeType":"50","messageId":"51","endLine":3,"endColumn":57},{"ruleId":"48","severity":1,"message":"54","line":3,"column":59,"nodeType":"50","messageId":"51","endLine":3,"endColumn":68},{"ruleId":"48","severity":1,"message":"55","line":3,"column":70,"nodeType":"50","messageId":"51","endLine":3,"endColumn":78},{"ruleId":"56","severity":1,"message":"57","line":20,"column":6,"nodeType":"58","endLine":20,"endColumn":8,"suggestions":"59"},{"ruleId":"48","severity":1,"message":"60","line":1,"column":17,"nodeType":"50","messageId":"51","endLine":1,"endColumn":26},{"ruleId":"48","severity":1,"message":"61","line":2,"column":10,"nodeType":"50","messageId":"51","endLine":2,"endColumn":14},{"ruleId":"48","severity":1,"message":"62","line":4,"column":64,"nodeType":"50","messageId":"51","endLine":4,"endColumn":75},{"ruleId":"48","severity":1,"message":"63","line":5,"column":83,"nodeType":"50","messageId":"51","endLine":5,"endColumn":93},{"ruleId":"48","severity":1,"message":"64","line":15,"column":12,"nodeType":"50","messageId":"51","endLine":15,"endColumn":18},{"ruleId":"48","severity":1,"message":"65","line":18,"column":10,"nodeType":"50","messageId":"51","endLine":18,"endColumn":17},{"ruleId":"56","severity":1,"message":"57","line":41,"column":8,"nodeType":"58","endLine":41,"endColumn":10,"suggestions":"66"},{"ruleId":"67","severity":1,"message":"68","line":481,"column":35,"nodeType":"69","endLine":481,"endColumn":76},"no-native-reassign",["70"],"no-negated-in-lhs",["71"],"no-unused-vars","'Col' is defined but never used.","Identifier","unusedVar","'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",["72"],"'useEffect' is defined but never used.","'Link' is defined but never used.","'FormControl' is defined but never used.","'Pagination' is defined but never used.","'mobile' is assigned a value but never used.","'reviews' is assigned a value but never used.",["73"],"react/jsx-no-duplicate-props","No duplicate props allowed","JSXAttribute","no-global-assign","no-unsafe-negation",{"desc":"74","fix":"75"},{"desc":"74","fix":"76"},"Update the dependencies array to be: [getReview]",{"range":"77","text":"78"},{"range":"79","text":"78"},[555,557],"[getReview]",[1254,1256]] [{"C:\\Users\\Korea\\Desktop\\2020winter\\search-page\\client\\src\\index.js":"1","C:\\Users\\Korea\\Desktop\\2020winter\\search-page\\client\\src\\reportWebVitals.js":"2","C:\\Users\\Korea\\Desktop\\2020winter\\search-page\\client\\src\\Components\\Paginations.js":"3","C:\\Users\\Korea\\Desktop\\2020winter\\search-page\\client\\src\\Components\\Place.js":"4","C:\\Users\\Korea\\Desktop\\2020winter\\search-page\\client\\src\\Pages\\App.js":"5","C:\\Users\\Korea\\Desktop\\2020winter\\search-page\\client\\src\\Pages\\Search.js":"6"},{"size":1133,"mtime":1610350393004,"results":"7","hashOfConfig":"8"},{"size":375,"mtime":1609072355927,"results":"9","hashOfConfig":"8"},{"size":2199,"mtime":1610343833899,"results":"10","hashOfConfig":"8"},{"size":5363,"mtime":1610610376162,"results":"11","hashOfConfig":"8"},{"size":1553,"mtime":1610514553145,"results":"12","hashOfConfig":"8"},{"size":39124,"mtime":1610627223933,"results":"13","hashOfConfig":"8"},{"filePath":"14","messages":"15","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"16"},"zqc0qw",{"filePath":"17","messages":"18","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"16"},{"filePath":"19","messages":"20","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"16"},{"filePath":"21","messages":"22","errorCount":0,"warningCount":6,"fixableErrorCount":0,"fixableWarningCount":0,"source":"23","usedDeprecatedRules":"16"},{"filePath":"24","messages":"25","errorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":"26","usedDeprecatedRules":"16"},{"filePath":"27","messages":"28","errorCount":0,"warningCount":5,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"C:\\Users\\Korea\\Desktop\\2020winter\\search-page\\client\\src\\index.js",[],["29","30"],"C:\\Users\\Korea\\Desktop\\2020winter\\search-page\\client\\src\\reportWebVitals.js",[],"C:\\Users\\Korea\\Desktop\\2020winter\\search-page\\client\\src\\Components\\Paginations.js",[],"C:\\Users\\Korea\\Desktop\\2020winter\\search-page\\client\\src\\Components\\Place.js",["31","32","33","34","35","36"],"import axios from 'axios';\r\nimport React, { useEffect, useState } from 'react';\r\nimport { Modal, Container, Row, Col, Button, Badge, Card, Accordion, Carousel } from 'react-bootstrap';\r\n\r\nfunction Place(props) {\r\n const [reviews, setReviews] = useState([])\r\n const getReview = () => {\r\n axios.get(`/api/review/${props.search.name}`)\r\n .then(res => {\r\n console.log(\"res.data=\", res.data)\r\n setReviews(res.data)\r\n })\r\n .catch(err => {\r\n console.log(err)\r\n })\r\n }\r\n\r\n useEffect(() => {\r\n getReview();\r\n }, [])\r\n\r\n\r\n return (\r\n <Modal {...props}\r\n size=\"xl\"\r\n keyboard=\"true\"\r\n variant=\"backdrop.in\"\r\n // show={lgShow}\r\n // onHide={() => setLgShow(false)}\r\n aria-labelledby=\"example-modal-sizes-title-lg\">\r\n <Modal.Header closeButton>\r\n <Modal.Title id=\"contained-modal-title-vcenter\" style={{ fontSize: '40px' }}>\r\n {props.index + 1}. {props.search.name}\r\n </Modal.Title>\r\n </Modal.Header>\r\n <Modal.Body className=\"show-grid\">\r\n <Container style={{ fontSize: '40px' }}>\r\n {reviews.map((review, index) => {\r\n return (\r\n <Row className=\"mt-4\">\r\n <a href={review.link}>{review.title}</a>\r\n <div>{review.summary}</div>\r\n </Row>\r\n )\r\n })}\r\n </Container>\r\n\r\n {/* <Accordion defaultActiveKey=\"0\">\r\n <Accordion.Toggle as={Button} variant=\"link\" eventKey=\"0\">\r\n <a className=\"mb-2\">다음의 블로그 보기</a>\r\n </Accordion.Toggle>\r\n <Accordion.Collapse eventKey=\"0\">\r\n <Card.Body><div>주도 전역을 지배하는 한라산은 남한에서 가장 높은 산으로 높이는 1,947.3m이다. 한라산이라는 이름은 산이 높아 산정에 서면 은하수를 잡아당길 수 있다는 뜻이며, 부악·원산·선산·두무악·영주산·부라산·혈망봉·여장군 등으로도 불려왔다.</div></Card.Body>\r\n </Accordion.Collapse>\r\n <Row>\r\n <Accordion.Toggle as={Button} variant=\"link\" eventKey=\"1\">\r\n <a className=\"mb-2\">네이버의 블로그 보기</a>\r\n </Accordion.Toggle>\r\n <Accordion.Collapse eventKey=\"1\">\r\n <Card.Body><div>한라산은 1966년 한라산 천연보호구역으로, 1970년 국립공원으로 지정되었다. 그리고 2002년에는 유네스코 생물권보전지역으로 지정되었으며 2007년에는 유네스코 세계자연유산으로 등재되었다. 2008년에는 물장오리오름 산정화구호 습지가 람사르 습지로 등록되어 보호 관리되고 있다</div></Card.Body>\r\n </Accordion.Collapse>\r\n </Row>\r\n <Row>\r\n <Accordion.Toggle as={Button} variant=\"link\" eventKey=\"2\">\r\n <a className=\"mb-2\">구글의 블로그 보기</a>\r\n </Accordion.Toggle>\r\n <Accordion.Collapse eventKey=\"2\">\r\n <Card.Body><div>한라산은 제주도에 있는 해발 1,947.06m, 면적 약 1,820km²의 화산으로, 제주도의 면적 대부분을 차지하고 있다. 정상에 백록담이라는 화산호가 있는데, 백록담이라는 이름은 흰 사슴이 물을 먹는 곳이라는 뜻에서 왔다고 전해진다.</div></Card.Body>\r\n </Accordion.Collapse>\r\n </Row>\r\n </Accordion>\r\n <Row style={{ color: 'white' }}>\r\n <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>\r\n </Row>\r\n // </Container>\r\n <Carousel>\r\n <Carousel.Item interval={1000}>\r\n <h3>다음 블로그</h3>\r\n <div>주도 전역을 지배하는 한라산은 남한에서 가장 높은 산으로 높이는 1,947.3m이다. 한라산이라는 이름은 산이 높아 산정에 서면 은하수를 잡아당길 수 있다는 뜻이며, 부악·원산·선산·두무악·영주산·부라산·혈망봉·여장군 등으로도 불려왔다.</div>\r\n </Carousel.Item>\r\n <Carousel.Item interval={1000}>\r\n <h3>네이버 블로그</h3>\r\n <div>한라산은 1966년 한라산 천연보호구역으로, 1970년 국립공원으로 지정되었다. 그리고 2002년에는 유네스코 생물권보전지역으로 지정되었으며 2007년에는 유네스코 세계자연유산으로 등재되었다. 2008년에는 물장오리오름 산정화구호 습지가 람사르 습지로 등록되어 보호 관리되고 있다</div>\r\n </Carousel.Item>\r\n <Carousel.Item interval={1000}>\r\n <h3>구글 블로그</h3>\r\n <div>한라산은 제주도에 있는 해발 1,947.06m, 면적 약 1,820km²의 화산으로, 제주도의 면적 대부분을 차지하고 있다. 정상에 백록담이라는 화산호가 있는데, 백록담이라는 이름은 흰 사슴이 물을 먹는 곳이라는 뜻에서 왔다고 전해진다.</div>\r\n </Carousel.Item>\r\n </Carousel> */}\r\n </Modal.Body>\r\n <Modal.Footer>\r\n <Button block onClick={props.onHide}>Close</Button>\r\n </Modal.Footer>\r\n </Modal>\r\n );\r\n}\r\n\r\nexport default Place;\r\n","C:\\Users\\Korea\\Desktop\\2020winter\\search-page\\client\\src\\Pages\\App.js",["37","38","39"],"import React, { useEffect, useState } from 'react';\r\nimport { Link, Redirect } from 'react-router-dom';\r\nimport ohuh from '../ohuh.PNG';\r\nimport { Container, Row, Form, Image, InputGroup, Button, Col, FormControl } from 'react-bootstrap';\r\n\r\nfunction App() {\r\n const [state, setState] = useState(false);\r\n const [search, setSearch] = useState(\"\");\r\n\r\n if (state !== false) {\r\n return <Redirect to={{\r\n pathname: `/search/${search}`,\r\n state: { id: search },\r\n }} />;\r\n }\r\n\r\n const handleChange = (e) => {\r\n setSearch(e.target.value);\r\n }\r\n\r\n const handleSubmit = () => {\r\n setState(true);\r\n }\r\n\r\n return (\r\n <Container className=\"vh-100 d-flex justify-content-md-center align-items-center\">\r\n <Col md={6} lassName=\" d-flex justify-content-center\">\r\n <Row style={{marginBottom:20}}>\r\n <Image src={ohuh} />\r\n </Row>\r\n <Row style={{marginBottom:500}}>\r\n <Form className=\"vw-100\" onSubmit={handleSubmit}>\r\n <InputGroup>\r\n <Form.Control\r\n size=\"lg\"\r\n placeholder=\"검색어를 입력하세요.\"\r\n aria-label=\"Large\"\r\n aria-describedby=\"inputGroup-sizing-sm\"\r\n onChange={handleChange}\r\n />\r\n <InputGroup.Append>\r\n <Button type='submit' variant=\"outline-secondary\">검색</Button>\r\n </InputGroup.Append>\r\n </InputGroup>\r\n </Form>\r\n </Row>\r\n </Col>\r\n </Container>\r\n );\r\n}\r\n\r\nexport default App;","C:\\Users\\Korea\\Desktop\\2020winter\\search-page\\client\\src\\Pages\\Search.js",["40","41","42","43","44"],{"ruleId":"45","replacedBy":"46"},{"ruleId":"47","replacedBy":"48"},{"ruleId":"49","severity":1,"message":"50","line":3,"column":33,"nodeType":"51","messageId":"52","endLine":3,"endColumn":36},{"ruleId":"49","severity":1,"message":"53","line":3,"column":46,"nodeType":"51","messageId":"52","endLine":3,"endColumn":51},{"ruleId":"49","severity":1,"message":"54","line":3,"column":53,"nodeType":"51","messageId":"52","endLine":3,"endColumn":57},{"ruleId":"49","severity":1,"message":"55","line":3,"column":59,"nodeType":"51","messageId":"52","endLine":3,"endColumn":68},{"ruleId":"49","severity":1,"message":"56","line":3,"column":70,"nodeType":"51","messageId":"52","endLine":3,"endColumn":78},{"ruleId":"57","severity":1,"message":"58","line":20,"column":6,"nodeType":"59","endLine":20,"endColumn":8,"suggestions":"60"},{"ruleId":"49","severity":1,"message":"61","line":1,"column":17,"nodeType":"51","messageId":"52","endLine":1,"endColumn":26},{"ruleId":"49","severity":1,"message":"62","line":2,"column":10,"nodeType":"51","messageId":"52","endLine":2,"endColumn":14},{"ruleId":"49","severity":1,"message":"63","line":4,"column":64,"nodeType":"51","messageId":"52","endLine":4,"endColumn":75},{"ruleId":"49","severity":1,"message":"64","line":5,"column":83,"nodeType":"51","messageId":"52","endLine":5,"endColumn":93},{"ruleId":"49","severity":1,"message":"65","line":15,"column":12,"nodeType":"51","messageId":"52","endLine":15,"endColumn":18},{"ruleId":"49","severity":1,"message":"66","line":16,"column":12,"nodeType":"51","messageId":"52","endLine":16,"endColumn":17},{"ruleId":"57","severity":1,"message":"67","line":51,"column":8,"nodeType":"59","endLine":51,"endColumn":10,"suggestions":"68"},{"ruleId":"69","severity":1,"message":"70","line":491,"column":35,"nodeType":"71","endLine":491,"endColumn":76},"no-native-reassign",["72"],"no-negated-in-lhs",["73"],"no-unused-vars","'Col' is defined but never used.","Identifier","unusedVar","'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",["74"],"'useEffect' is defined but never used.","'Link' is defined but never used.","'FormControl' is defined but never used.","'Pagination' is defined but never used.","'mobile' is assigned a value but never used.","'place' is assigned a value but never used.","React Hook useEffect has missing dependencies: 'getImg' and 'getPlace'. Either include them or remove the dependency array.",["75"],"react/jsx-no-duplicate-props","No duplicate props allowed","JSXAttribute","no-global-assign","no-unsafe-negation",{"desc":"76","fix":"77"},{"desc":"78","fix":"79"},"Update the dependencies array to be: [getReview]",{"range":"80","text":"81"},"Update the dependencies array to be: [getImg, getPlace]",{"range":"82","text":"83"},[555,557],"[getReview]",[1644,1646],"[getImg, getPlace]"]
\ No newline at end of file \ No newline at end of file
[0111/154710.316:ERROR:directory_reader_win.cc(43)] FindFirstFile: 지정된 경로를 찾을 수 없습니다. (0x3) [0111/154710.316:ERROR:directory_reader_win.cc(43)] FindFirstFile: 지정된 경로를 찾을 수 없습니다. (0x3)
[0112/191834.168: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)
...@@ -13,26 +13,36 @@ function Search(props) { ...@@ -13,26 +13,36 @@ 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([])
const [imgUrl, setImgUrl] = 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 [reviews, setReviews] = useState([]) const getPlace = () => {
axios.get(`/api/search/places/${search}`)
const getReview = () => { .then(res => {
console.log('search', search) console.log("places=", res.data)
axios.get(`/api/search/${search}`) setPlace(res.data)
.then(res => { })
console.log("res.data22222222=", res.data) .catch(err => {
setReviews(res.data) console.log('search.places발생', err)
}) })
.catch(err => { }
console.log('search.err발생',err)
})
}
useEffect(() => { useEffect(() => {
getReview() getImg()
getPlace()
if (window.innerWidth < 960) { if (window.innerWidth < 960) {
setMobile(true) setMobile(true)
} else { } else {
...@@ -494,6 +504,7 @@ function Search(props) { ...@@ -494,6 +504,7 @@ function Search(props) {
</InputGroup> </InputGroup>
</Form> </Form>
</Row> </Row>
<Image src={imgUrl} />
<Row className="d-flex flex-wrap"> <Row className="d-flex flex-wrap">
{pagePlace.map((place, index) => { {pagePlace.map((place, index) => {
return ( return (
......
This diff is collapsed.
...@@ -3,31 +3,51 @@ import cheerio from 'cheerio' ...@@ -3,31 +3,51 @@ import cheerio from 'cheerio'
import fs from 'fs' import fs from 'fs'
import axios from 'axios'; import axios from 'axios';
const search = async (req, res) => { const searchPlace = async (req, res) => {
console.log("여기까지는 옵니다~")
console.log("여기까지 도착합니다.@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
console.log(req.params.search)
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 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((response) => { .then((response) => {
const html = response.data const html = response.data
fs.writeFileSync("googlez.txt", html, { encoding: 'utf8' });
let $1 = cheerio.load(html); let $1 = cheerio.load(html);
let reviews = []
let places = []
$1('.kCrYT').each(function (i) { $1('.kCrYT').each(function (i) {
if ($1(this).find('h3').text()) { if ($1(this).find('h3').text()) {
reviews[i] = { name: $1(this).find('h3').text(), link: ($1(this).find('a').attr('href')) } places[i] = { name: $1(this).find('h3').text(), link: ($1(this).find('a').attr('href')) }
} else if ($1(this).find('.s3v9rd').find('.s3v9rd').text()) { } else if ($1(this).find('.s3v9rd').find('.s3v9rd').text()) {
reviews[i - 1] = { ...reviews[i - 1], address: $1(this).find('.s3v9rd').find('.s3v9rd').text() } places[i - 1] = { ...places[i - 1], address: $1(this).find('.s3v9rd').find('.s3v9rd').text() }
reviews = reviews.filter(e => e) places = places.filter(e => e)
} }
}) })
console.log("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", places)
res.send(places)
})
}
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"
console.log("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@",reviews) axios.get(imgUrl)
res.send(reviews) .then((response) => {
const html = response.data
let $1 = cheerio.load(html);
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)
res.send(images)
}) })
} }
export default { search }
export default { searchImg, searchPlace }
...@@ -23,7 +23,7 @@ const search = async (req, res) => { ...@@ -23,7 +23,7 @@ const search = async (req, res) => {
} }
}) })
console.log("*******************************************",reviews) // console.log("*******************************************",reviews)
res.send(reviews) res.send(reviews)
}) })
} }
......
...@@ -3,7 +3,11 @@ import place from '../controllers/place.controller.js' ...@@ -3,7 +3,11 @@ 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')
.get(place.search) .get(place.searchImg)
router.route('/api/search/places/:search')
.get(place.searchPlace)
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