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

181
Views
I have trouble with json is no defined in puppetter how I can fix this

Here at first I login to linkedin and create else one tab which I can open the linkedin link I am taking from incubators json looks like; [{linkeding: "url"}], And I need put them to Array.from() but there said:

Error: Evaluation failed: ReferenceError: json is not defined

How I can fix this

const puppeteer = require("puppeteer");
const json = require("./../incubators.json");

(async () => {
  const browser = await puppeteer.launch({ headless: false });
  const page = await browser.newPage();
  await page.goto("https://www.linkedin.com/");
  await page.type("#session_key", "gamerlex2004@gmail.com");
  await page.type("#session_password", "bakai987");
  await Promise.all([
    page.click(
      "#main-content > section.section.hero > div > div > form > button"
    ),
    page.waitForNavigation({ waitUntil: "networkidle0" }),
  ]);

  const page2 = await browser.newPage();
  await page2.setViewport({ width: 1200, height: 720 });

  const urls = await page2.evaluate(() =>
    Array.from(json, (element) => element.linkedin_url)
  );

  for (let i = 0, total_urls = urls.length; i < total_urls; i++) {
    await page2.goto(urls[i]);
    await page2
      .evaluate(async () => {
        let data = [];
        let elements = document.querySelectorAll(
          "body > div.application-outlet > div.authentication-outlet > div > div.scaffold-layout.scaffold-layout--breakpoint-xl.scaffold-layout--main-aside.scaffold-layout--reflow > div"
        );

        for (const element of elements) {
          data.push({
            linkedinUrl: page2.url().toString() || "",
            linkedinProfileUrl:
              element.querySelector("#ember45")?.getAttribute("src") || "",
          });
        }

        return data; // Return our data array
      })
      .then((data) => {
        fs.appendFile("./image.json", JSON.stringify(data), (err) =>
          err ? console.log(err) : null
        );
      });
  }
})();
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!