Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

190
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda