How to get the content of a div tag when scraping with puppeteer and NodeJs

I heard of this library called puppeteer and is usefulness in scraping web pages. so i decided to scrape a gaming site content so I can store it data and go through it later.

But after i copied the XPATH of the div tag I want puppeteer to scrape it content, its returning Empty string Please what am I doing wrong.

This is the url am trying to scrape here

i want to scrape the div tag where the result of the 6 different color ball are being displayed.
so i can get the number of those colors every 45 seconds.

const puppeteer = require("puppeteer");

async function scrapeData(url){
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(url);

const [dataReceived] = await page.$x('/html/body/div[1]/div/div/div/footer/div[2]/div[1]/div/div[1]/div[2]/div/div');
const elContent = await dataReceived.getProperty('textContent');
const elValue = await elContent.jsonValue();
console.log("just testing");

here is the image of the returned empty string in vscode terminal

enter image description here

31 thoughts on “How to get the content of a div tag when scraping with puppeteer and NodeJs”

  1. Pingback: sildenafil
  2. Pingback: viagra pill
  3. Pingback: viagra sale
  4. Pingback: otc viagra
  5. Pingback: cialis shop
  6. Pingback: how to buy cialis
  7. Pingback: viagra online
  8. Pingback: sildenafil online
  9. Pingback: overnight cialis

Leave a Comment