const axios = require("axios");
const cheerio = require("cheerio");
const log = console.log;

const getHtml = async () => {
  try {
    return await axios.get(
      "https://search.naver.com/search.naver?where=nexearch&sm=tab_jum&query=%EC%83%8C%EB%93%9C%EC%9C%84%EC%B9%98"
    );
  } catch (error) {
    console.error(error);
  }
};

getHtml()
  .then((html) => {
    let ulList = [];
    const $ = cheerio.load(html.data);
    const $bodyList = $(
      "div.api_subject_bx div.keyword_challenge_wrap div.challenge_wrap ul"
    ).children("li");
    console.log($bodyList);

    $bodyList.each(function (i, elem) {
      ulList[i] = {
        tag: $(this).find("div.more_box a span.name ").text(),
        title: $(this)
          .find("div.keyword_box_wrap div.detail_box div.dsc_area a.name_link")
          .text(),
        influencer: $(this)
          .find(
            "div div.user_box div.user_box_inner div.user_info_bx div.user_area a"
          )
          .text(),
        created: $(this).find("div div.detail_box div.dsc_area a span.date"),
      };
    });

    const data = ulList.filter((n) => n.tag);
    return data;
  })
  .then((res) => log(res));

태그:

카테고리:

업데이트:

댓글남기기