Cuando ejecuto esta función, obtengo el resultado esperado a través de console.log, pero no se sale de la función. ¿Por qué es ese el caso?
const puppeteer = require('puppeteer'); async function scrape(url) { const browser = await puppeteer.launch(); const page = await browser.newPage(); const target = await page.goto(url); const waiting = await page.waitForXPath('XPATH...'); const [el] = await page.$x('XPATH...'); const txt = await el.getProperty('textContent'); const rawTxt = txt.jsonValue(); console.log(rawTxt); }Intenta cerrar Puppeteer cuando completes tu tarea.
// ... your code browser.close() const puppeteer = require('puppeteer'); async function scrape(url) { const browser = await puppeteer.launch(); const page = await browser.newPage(); const target = await page.goto(url); const waiting = await page.waitForXPath('XPATH...'); const [el] = await page.$x('XPATH...'); const txt = await el.getProperty('textContent'); const rawTxt = txt.jsonValue(); console.log(rawTxt); browser.close() // <-- }