Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

155
Views
Web Scraping using Node JS Puppeteer

I want to scrape some vessel details using Node Js and Puppeteer. When I try to scrape data , the result is showing null. I don't have any idea about why I am getting output like this. Here is my code.

index.js

const puppeteer = require("puppeteer");
const Scraper = require("./scrapers/class-based");

/**
 * Run Scraper
 */
(async () => {
  let browser;
  let page;

  try {
    browser = await puppeteer.launch({
      headless: false
    });

    page = await browser.newPage();

    await new Scraper(browser, page).main();
  } catch (error) {
    console.log(error.stack || error);
  }

  await browser.close();
})();

class.js

const writeFileSync = require("fs").writeFileSync;

/**
 * @class Scraper
 */
module.exports = class Scraper {
  /**
   * @constructor
   */
  constructor(browser, page) {
    this.browser = browser;
    this.page = page;

    this.standings = [];
    this.url = "https://www.myshiptracking.com/vessels";
  }

  
    // @method main
   
  async main() {
    await this.page.goto(this.url, { waitUntil: "domcontentloaded" });

    this.standings = await this.page.evaluate(() =>
      Array.from(document.querySelectorAll("tbody > tr")).map(team => [
        team.querySelector("td:nth-child(4)").getAttribute("data-value"),
        team.querySelector("td:nth-child(6)").getAttribute("data-value")
      ])
    );

    this.writeToJson();
  }

  /**
   * @method writeToJson
   */
  writeToJson() {
    writeFileSync("./data/standings.json", JSON.stringify(this.standings));
  }
};

output: Standings.json

[[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null]]

I am new to Node JS and Scraping. I followed tutorial and got answer like this. If anyone could help it would be really helpful. Thanks.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!