Category : puppeteer

When I try to execute the following async function inside of an evaluate function via React, it fails. Here’s the function code: await page.evaluate(async () => { return new Promise(resolve => { let totalHeight = 0 const distance = 500 const timer = setInterval(() => { const scrollHeight = 10509 window.scrollBy(0, distance) totalHeight += distance ..

Read more

I am working on a Puppeteer web-scraper, in which the Page.evaluate function takes an object of global variables as its argument (to use them in the DOM context)… The following works fine: await page.evaluate(({parameter_A, parameter_B, parameter_C}) => { some code }, {parameter_A, parameter_B, parameter_C} ); However, when I try to define a separate object to ..

Read more

Is there a way to download mp4 or video files using puppeteer? Here’s an example of what I want to download https://www.w3schools.com/html/mov_bbb.mp4 Here’s my script so far async downloadVideo(link = ”) { try { this.browser = await puppeteer.launch({ headless: false, args: [‘–no-sandbox’] }) this.page = await this.browser.newPage(); if (!link) { throw new Error(`No link provided, ..

Read more

Whenever I need to scroll down a page using puppeteer i’ve been using this solution: async function autoScroll(page) { await page.evaluate(async () => { await new Promise((resolve, reject) => { var totalHeight = 0; var distance = 100; var timer = setInterval(() => { var scrollHeight = document.body.scrollHeight; window.scrollBy(0, distance); totalHeight += distance; if (totalHeight ..

Read more