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