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

195
Vistas
puppeteer/Javascript check for network responses in a loop

Using puppeteer I am trying to achieve something where I can capture network responses on selection of a dropdown item. It does not have to be immediate, we can select all options one after another, and can use network response later as well, as long as it works smoothly.

(async () => {
  const browser = await puppeteer.launch(chromeoptions);
  const page = await browser.newPage();
  page.target().createCDPSession();
  page.setDefaultNavigationTimeout(1000000);
}

async function getAppointmentData() {
  await page.goto('go to the page URL')
  let appointmentData = [];
  await page.waitForSelector(
      "[id*=dropdownId]"
    );

  for (let option of options) {
    // Selecting an option from a dropdown trigger a network call that I need to record
    await page.select(
        "select#dropdownId",
        option?.id
      )

   /* Check for a network call that contains that option?.id or .json?details
      Sample URL >>>> https://abc.test.com/en/10.json?details  [Where 10 is options?id]
   */
  // After All Items in dropdown is selected, Want to insert response [Array of Objects] to an object like:
   appointmentData.push({
     id: options?.id;
     data: [Array of Objects]
    }]

  } // For Loop Ends

  processAppointments(appointmentData )

}

processAppointments(data) {
  /// 
}

getAppointmentData();
})();

I tried using page.on() and other methods but not helpful. can someone please help me out here? been stuck for almost one week.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Your page.on should look something like:

page.on("response", response => {
  let match = response.url().match(/(\d+).json/)
  if(match){
    console.log(`option ${match[1]}`)
  }
})
about 4 years ago · Juan Pablo Isaza Denunciar
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