Commit 555bea50 authored by Lee SeoYeon's avatar Lee SeoYeon
Browse files

.

parent c8d82d40
This diff is collapsed.
......@@ -22,8 +22,6 @@ function Bookmark() {
// return true;
// }
// }
// const [index, setIndex] = useState(1);
// const [showSet, setShowSet] = useState([false, false, false, false]);
const add_Page = [{
title:'즐겨찾기1',
url:'http://localhost:3000',
......@@ -51,7 +49,7 @@ function Bookmark() {
</Navbar>
<Form>
<ListGroup>
<ListGroup.Item action href="/">북마크1</ListGroup.Item>
<ListGroup.Item action href="">북마크1</ListGroup.Item>
<ListGroup.Item>북마크2</ListGroup.Item>
</ListGroup>
</Form>
......
......@@ -2,10 +2,10 @@ 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, Nav, Navbar } from 'react-bootstrap';
import { Container, Form, Row, Col, Card, Image, InputGroup, FormControl, Button, Modal } from 'react-bootstrap';
import Paginations from './pagination.js';
import { addFavorite } from './Bookmark.js'
import * as Icon from 'react-bootstrap-icons';
import axios from "axios";
function Search(props) {
const endPage = 10;
......@@ -14,6 +14,10 @@ function Search(props) {
const [showSet, setShowSet] = useState([false, false, false, false]);
const [search, setSearch] = useState(props.location.state.id);
const [mobile, setMobile] = useState();
const [show, setShow] = useState(false);
const handleClose = () => setShow(false);
const handleShow = () => setShow(true);
useEffect(() => {
if (window.innerWidth < 960) {
......@@ -57,6 +61,9 @@ function Search(props) {
setIndex(num);
}
// async function bookmarkSave() {
// await axios.put('/api/users', {userId:userId, bookmarkId:bookmarkId})
// }
const handleChange = (e) => {
setSearch(e.target.value);
......@@ -106,31 +113,34 @@ function Search(props) {
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}<Button onClick={handleShow}> <Modal
<Button variant="outline-info" style={{ marginLeft: "60vh" }} onClick={handleShow}><Icon.BookmarkStar size={30} /> <Modal
show={show}
onHide={handleClose}
backdrop="static"
keyboard={false}
><Form>
>
<Modal.Header closeButton>
<Modal.Title id="contained-modal-title-vcenter" style={{ fontSize: '30px' }}>북마크 추가됨
</Modal.Title>
</Modal.Header><Form>
<Form.Group controlId="formBasicEmail">
<Form.Label>이름</Form.Label>
<Form.Control type="email" placeholder="Enter email" />
<Form.Label style={{ fontSize: '20px' }}>이름</Form.Label>
<Form.Control type="email" />
<Form.Text className="text-muted">
We'll never share your email with anyone else.
</Form.Text>
</Form.Group>
<Form.Group controlId="formBasicPassword">
<Form.Label>폴더</Form.Label>
{/* <Form.Group controlId="formBasicPassword">
<Form.Label style={{ fontSize: '20px' }}>폴더</Form.Label>
<Form.Control type="password" placeholder="Password" />
</Form.Group>
<Form.Group controlId="formBasicCheckbox">
<Form.Check type="checkbox" label="Check me out" />
</Form.Group>
<Button variant="primary" type="submit">
Submit
</Button>
</Form></Modal></Button></Card.Title>
</Form.Group> */}
<Modal.Footer>
<Button variant="primary" type="submit">저장</Button>
<Button onClick={props.onHide}>삭제</Button>
</Modal.Footer>
</Form></Modal></Button>
<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" }} >
......@@ -147,8 +157,8 @@ function Search(props) {
)
})}
</Row>
{ console.log(showSet) }
{/* show가 전부 true로 바뀌어서 전부 다 보이게 되는 것이다. */ }
{ console.log(showSet)}
{/* show가 전부 true로 바뀌어서 전부 다 보이게 되는 것이다. */}
<Row className="mt-2 d-flex justify-content-center">
<Paginations index={index} endPage={endPage} handlePage={handlePage}></Paginations>
</Row>
......
......@@ -164,6 +164,11 @@
"resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
"integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24="
},
"bootstrap-icons": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/bootstrap-icons/-/bootstrap-icons-1.3.0.tgz",
"integrity": "sha512-w6zQ93p626zmPDqDtET7VdB9EkoDtfmCBV53hunjntoCke6X5LafXf6TxPAP+ImjRAhhxAyA/sjzQnHBY0uoiQ=="
},
"boxen": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/boxen/-/boxen-4.2.0.tgz",
......@@ -908,6 +913,11 @@
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
},
"js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="
},
"json-buffer": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.0.tgz",
......@@ -1012,6 +1022,14 @@
"resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz",
"integrity": "sha1-DdOXEhPHxW34gJd9UEyI+0cal6w="
},
"loose-envify": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
"integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
"requires": {
"js-tokens": "^3.0.0 || ^4.0.0"
}
},
"lowercase-keys": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz",
......@@ -1338,6 +1356,16 @@
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="
},
"prop-types": {
"version": "15.7.2",
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz",
"integrity": "sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==",
"requires": {
"loose-envify": "^1.4.0",
"object-assign": "^4.1.1",
"react-is": "^16.8.1"
}
},
"proxy-addr": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz",
......@@ -1401,6 +1429,19 @@
"strip-json-comments": "~2.0.1"
}
},
"react-bootstrap-icons": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/react-bootstrap-icons/-/react-bootstrap-icons-1.2.3.tgz",
"integrity": "sha512-VPQFuFMVwsK93FTbvE/8InUbX5irc2VlQbCOiMvj80oei6+xek0Q5sOpHPdgVRUn2BeiCAAc9OEOgrebZLWLMA==",
"requires": {
"prop-types": "^15.7.2"
}
},
"react-is": {
"version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ=="
},
"readable-stream": {
"version": "2.3.7",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz",
......
......@@ -7,12 +7,14 @@
"dependencies": {
"axios": "^0.21.1",
"bcryptjs": "^2.4.3",
"bootstrap-icons": "^1.3.0",
"cheerio": "^1.0.0-rc.5",
"express": "^4.17.1",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.11.11",
"multer": "^1.4.2",
"nodemon": "^2.0.7",
"react-bootstrap-icons": "^1.2.3",
"validator": "^13.5.2"
},
"devDependencies": {},
......
import Review from '../models/Review.js'
import cheerio, { html } from "cheerio";
import jschardet from 'jschardet'
import iconv from 'iconv'
import fs from 'fs'
import axios from 'axios';
import { nextTick } from 'process';
const Iconv = iconv.Iconv
const search = async (req, res, next) => {
// 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("한라산") + "+site%3Atistory.com&page_no=1"
let reviews = []
try {
axios.get(url)
// .then(anyToUtf8)
.then((html) => {
const $1 = cheerio.load(html.data);
$1('.kCrYT').each(function (i) {
const searchParams = new URLSearchParams($1(this).find('a').attr('href'));
const title = $1(this).find('h3').text()
const link = searchParams.get("/url?q")
const summary = $1(this).find('.s3v9rd').find('.s3v9rd').text()
const response = axios.get(link)
console.log(response)
// const $2 = cheerio.load(toString(response.data));
let content = "없음"
// if ($2('.tt_article_useless_p_margin').text()) {
// content = $2('.tt_article_useless_p_margin').text()
// }
if (title) {
reviews[i] = { title: title, link: link, content: content }
} else if (summary) {
reviews[i - 1] = { ...reviews[i - 1], summary: summary }
reviews = reviews.filter(e => e)
}
// reviews.forEach((review, i) => {
// axios.get(review.link)
// .then((html) => {
// const $2 = cheerio.load(html.data);
// let content = '없음'
// if ($2('.tt_article_useless_p_margin').text()) {
// content = $2('.tt_article_useless_p_margin').text()
// }
// // fs.writeFileSync(`tistory${i}.txt`, '\ufeff' + html.data, { encoding: 'utf8' });
// // console.log(`${i}번째, ${review.content}`)
// review["content"] = content
// // console.log(review)
// })
// })
// // const review = new Review(reviews).save()
})
res.send(reviews)
})
} catch (error) {
console.log(error)
res.status(500).send('리뷰 저장 에러')
}
}
const getReview = (link) => {
let content = '없음'
const res = axios.get(link)
console.log(res)
// const $2 = cheerio.load(res.data);
// if ($2('.tt_article_useless_p_margin').text()) {
// content = $2('.tt_article_useless_p_margin').text()
// }
console.log(content)
return content
}
export default { search, getReview }
\ No newline at end of file
import Review from '../models/Review.js'
import cheerio, { html } from "cheerio";
import jschardet from 'jschardet'
import iconv from 'iconv'
import fs from 'fs'
import axios from 'axios';
import { nextTick } from 'process';
import { response } from 'express';
const Iconv = iconv.Iconv
const search = async (req, res, next) => {
const url = "https://www.google.com/search?q=" + encodeURI(req.params.search) + "+site%3Atistory.com&page_no=1"
let reviews = []
try {
axios.get(url)
.then((response1) => {
const $1 = cheerio.load(response1.data);
$1('.kCrYT').each(function (i) {
const searchParams = new URLSearchParams($1(this).find('a').attr('href'));
const title = $1(this).find('h3').text()
const link = searchParams.get("/url?q")
const summary = $1(this).find('.s3v9rd').find('.s3v9rd').text()
if (title) {
reviews[i] = { title: title, link: link, }
} else if (summary) {
reviews[i - 1] = { ...reviews[i - 1], summary: summary }
reviews = reviews.filter(e => e)
}
// const review = new Review(reviews).save()
})
res.send(reviews)
})
} catch (error) {
// reviews.forEach((review) => {
// axios.get(review.link)
// .then((response2) => {
// const $2 = cheerio.load(response2.data);
// let content = ''
// if ($2('.tt_article_useless_p_margin').text()) {
// content = $2('.tt_article_useless_p_margin').text()
// }
// review = { content: content }
// console.log("dkssud")
// })
// console.log("dkssud")
// })
// console.log(content)
res.status(500).send(error)
}
}
const getReview = async (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()
}
console.log(content, "getReiview")
return content
}
export default { search, getReview }
\ No newline at end of file
......@@ -6,53 +6,6 @@ import cheerio from "cheerio";
import axios from 'axios';
// const Iconv = iconv.Iconv
// const search = async (req, res) => {
// 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
// axios.get(url)
// // .then(anyToUtf8)
// .then((html) => {
// // fs.writeFileSync("googlez.txt", '\ufeff' + html, { encoding: 'utf8' });
// let $1 = cheerio.load(html.data);
// let reviews = []
// $1('.kCrYT').each(function (i) {
// let link = ""
// if ($1(this).find('a').attr('href')) {
// link = ($1(this).find('a').attr('href')).match(editUrl)
// }
// reviews[i] = {
// title: $1(this).find('h3').text(),
// link: link,
// summary: $1(this).find('.s3v9rd').text(),
// }
// })
// // reviews.forEach((review, i) => {
// // axios.get(review.link)
// // .then((html) => {
// // let $2 = cheerio.load(html.data);
// // $2('').each(function(i){
// // review.content($2(this).find(''.text()))
// // })
// // })
// // })
// console.log(reviews)
// res.send(reviews)
// })
// // function anyToUtf8(str) {
// // const { encoding } = jschardet.detect(str); // 웹페이지 문서의 인코딩 타입을 확인
// // const iconv = new Iconv(encoding, "utf-8//translit//ignore"); // euc-kr 인코딩변환
// // return iconv.convert(str).toString();
// // }
// // try {
// // const newPlace = await new Place({
// // name: req.params.search,
// // address,
// // img,
// // })
// // }
const search = async (req, res, next) => {
try {
let reviews = []
......
import mongoose, { isValidObjectId } from "mongoose";
const { String } = mongoose.Schema.Types
const { Array } = mongoose.Schema.Types
const UserSchema = new mongoose.Schema({
name: {
......@@ -23,9 +24,10 @@ const UserSchema = new mongoose.Schema({
default: 'user',
enum: ['user', 'admin', 'root']
},
// avatarUrl: {
// type:
// },
bookmark: {
type: Array,
required: true,
}
}, {
timestamps: true
})
......
......@@ -6,10 +6,6 @@ const router = express.Router()
router.route('/api/users/signup')
.post(userCtrl.signup)
router.route('/api/users/profile/:userId')
.get(userCtrl.getProfile)
.put(userCtrl.profileUpload, userCtrl.update)
router.param('userId', userCtrl.userById)
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