Commit 2813e438 authored by Kim, Chaerin's avatar Kim, Chaerin
Browse files

parent 517cbcbb
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) => {
try {
let reviews = []
let content = []
Review.find()
const url = "https://www.google.com/search?q=" + encodeURI(req.params.search) + "+site%3Atistory.com&page_no=1"
const response1 = await axios.get(url)
// console.log(response1.data)
......@@ -32,7 +31,9 @@ const search = async (req, res, next) => {
promiseReview = promiseReview.filter(e => typeof (e) === 'string')
reviews.forEach(async (review, i) => {
review["content"] = promiseReview[i]
const reviews = new Review(review).save()
})
res.send(reviews)
} catch (error) {
console.log(error)
......
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