Commit 3515ba65 authored by baesangjune's avatar baesangjune
Browse files

.

parent fae4ae5a
This diff is collapsed.
......@@ -11,19 +11,18 @@ const search = async (req, res) => {
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);
.then((response) => {
const html = response.data
fs.writeFileSync("googlez.txt", html, { encoding: 'utf8' });
let $1 = cheerio.load(html);
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').find('.s3v9rd').text(),
if ($1(this).find('h3').text()) {
reviews[i] = { title: $1(this).find('h3').text(), link: ($1(this).find('a').attr('href')) }
} else if ($1(this).find('.s3v9rd').find('.s3v9rd').text()) {
reviews[i - 1] = { ...reviews[i - 1], summary: $1(this).find('.s3v9rd').find('.s3v9rd').text() }
reviews = reviews.filter(e => e)
}
})
// reviews.forEach((review, i) => {
......@@ -36,7 +35,7 @@ const search = async (req, res) => {
// })
// })
console.log(reviews)
console.log("*******************************************",reviews)
res.send(reviews)
})
// function anyToUtf8(str) {
......
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