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

151
Views
Cómo hacer que el titiritero devuelva algo diferente si se carga un elemento específico

Estoy tratando de obtener valores de una página usando titiritero, el objetivo principal es extraer una URL si el contenido es válido, sin embargo, la página puede devolver un error dentro de la etiqueta ap.

 async function example() { const browser = await puppeteer.launch({ headless: true, }); const page = await browser.newPage(); await page.goto('https://example.com'); // The page might load an error inside of ap element // I don't want to block the rest of the script using await page.waitForSelector('p', {timeout: 5000}) .then( async () => { const pString = await page.evaluate(() => { return document.querySelector('p').innerHTML; }); console.log(pString); if(pString.includes('error')) { console.log('Page contains an error'); //i need to make the main function 'return' if this happens } }) // Wait for the link to load if everything is ok await page.waitForSelector('a', {timeout: 5000}); const link = await page.$('a'); // other stuff }

No puedo encontrar una forma adecuada de hacer esto sin tener que esperar el tiempo de espera

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!