이제 파싱을 해보자.
우선 따라쳐라.
const puppeteer = require("puppeteer");
const main = async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto(
    "https://sports.news.naver.com/kbaseball/record/index.nhn?category=kbo",
    { waitUntil: "networkidle2" }
  );
  await page.waitFor(5000);
  const teamRank = await page.waitFor(
  //id는# class는. 다 알잖아요
    "tbody#regularTeamRecordList_table>tr:nth-child(1)>td.tm>div>span"
  );
  const txtTeamRank = await page.evaluate(
    teamRank => teamRank.textContent,
    teamRank
  );
  console.log("1등 팀은 : ", txtTeamRank);
  await browser.close();
};
main();
이런식으로 파싱 해올수 있다.
'it > Node.js' 카테고리의 다른 글
| Puppeteer를 이용한 크롤링(Crawling) - HTML (0) | 2020.03.09 | 
|---|---|
| Puppeteer를 이용한 크롤링(Crawling) - 스크린샷 (0) | 2020.03.09 | 
| Puppeteer를 이용한 크롤링(Crawling) (0) | 2020.03.08 | 
| 윈도우 node.js 설치 (0) | 2017.03.07 | 
| node.js oracle db 설치 (0) | 2015.06.25 | 



