Commit 380f73b7 authored by baesangjune's avatar baesangjune
Browse files

review

parent c8e037b0
This diff is collapsed.
[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)
...@@ -7,6 +7,7 @@ function Place(props) { ...@@ -7,6 +7,7 @@ function Place(props) {
const getReview = () => { const getReview = () => {
axios.get(`/api/review/${props.search.name}`) axios.get(`/api/review/${props.search.name}`)
.then(res => { .then(res => {
console.log("res.data=", res.data)
setReviews(res.data) setReviews(res.data)
}) })
.catch(err => { .catch(err => {
...@@ -42,9 +43,9 @@ function Place(props) { ...@@ -42,9 +43,9 @@ function Place(props) {
</Row> </Row>
) )
})} })}
</Container> </Container>
{/* <Accordion defaultActiveKey="0"> {/* <Accordion defaultActiveKey="0">
<Accordion.Toggle as={Button} variant="link" eventKey="0"> <Accordion.Toggle as={Button} variant="link" eventKey="0">
<a className="mb-2">다음의 블로그 보기</a> <a className="mb-2">다음의 블로그 보기</a>
</Accordion.Toggle> </Accordion.Toggle>
......
...@@ -3,48 +3,44 @@ import cheerio from "cheerio"; ...@@ -3,48 +3,44 @@ import cheerio from "cheerio";
import express from 'express'; import express from 'express';
import request from 'request-promise' import request from 'request-promise'
import jschardet from 'jschardet' import jschardet from 'jschardet'
import iconv from 'iconv' // import iconv from 'iconv'
import fs from 'fs' import fs from 'fs'
const Iconv = iconv.Iconv // const Iconv = iconv.Iconv
const signup = async (req, res) => { const signup = async (req, res) => {
res.send("안녕하세요") res.send("안녕하세요")
} }
const search = async (req, res) => { const search = async (req, res) => {
const url = "https://www.google.com/search?q=" + encodeURI(req.params.search) + "+site%3Atistory.com" + '&page_no=1' // console.log(req.params.search)
// console.log("req", req)
const url = "https://www.google.com/search?q=%ED%95%9C%EB%9D%BC%EC%82%B0%20site%3Atistory.com&oq=tistory&aqs=chrome..69i57j0l4j69i60l3.1746j0j4&sourceid=chrome&ie=UTF-8&ved=2ahUKEwis_bSFz4buAhWVdXAKHU0tBaoQ2wF6BAgIEAE&ei=T1D1X-yZD5XrwQPN2pTQCg"
// const url=
request(url) request(url)
.then(anyToUtf8) // .then(anyToUtf8)
.then((html) => { .then((html) => {
// fs.writeFileSync("googlez.txt", '\ufeff' + html, { encoding: 'utf8' }); // fs.writeFileSync("googlez.txt", '\ufeff' + html, { encoding: 'utf8' });
let $ = cheerio.load(html, null, false); let $ = cheerio.load(html, null, false);
let places = [] let places = []
$('.kCrYT').each(function (i) { $('.kCrYT').each(function (i) {
const review = await Review.findOne({ link: $(this).find('a').attr('href') })
if (!user) {
const newReview = await new Review({
name,
email,
password: hash
}).save()
}
places[i] = { places[i] = {
title: $(this).find('h3').text(), title: $(this).find('h3').text(),
link: $(this).find('a').attr('href'), link: $(this).find('a').attr('href'),
summary: $(this).find('.s3v9rd').text(), summary: $(this).find('.s3v9rd').find('.s3v9rd').text(),
} }
}) })
console.log("places***********************************************",places)
// console.log(places)
res.send(places) res.send(places)
}) })
function anyToUtf8(str) { // function anyToUtf8(str) {
const { encoding } = jschardet.detect(str); // const { encoding } = jschardet.detect(str);
console.log("source encoding = " + encoding); // console.log("source encoding = " + encoding);
const iconv = new Iconv(encoding, "utf-8//translit//ignore"); // const iconv = new Iconv(encoding, "utf-8//translit//ignore");
return iconv.convert(str).toString(); // return iconv.convert(str).toString();
} // }
// try { // try {
// const newPlace = await new Place({ // const newPlace = await new Place({
// name: req.params.search, // name: req.params.search,
...@@ -55,6 +51,4 @@ const search = async (req, res) => { ...@@ -55,6 +51,4 @@ const search = async (req, res) => {
// } // }
} }
const
export default { signup, search } export default { signup, search }
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