Puppeteer Scraper avatar
Puppeteer Scraper

Pricing

Pay per usage

Go to Store
Puppeteer Scraper

Puppeteer Scraper

Developed by

Apify

Apify

Maintained by Apify

Crawls websites with the headless Chrome and Puppeteer library using a provided server-side Node.js code. This crawler is an alternative to apify/web-scraper that gives you finer control over the process. Supports both recursive crawling and list of URLs. Supports login to website.

5.0 (5)

Pricing

Pay per usage

140

Total users

6.8k

Monthly users

862

Runs succeeded

>99%

Issue response

44 days

Last modified

23 days ago

MP

Delay or setTimeout() FUNCTION

Closed

modest_programmer opened this issue
10 months ago

the scraper is not responding to a setTimeout function.

I want the Apify puppeteer scraper to return some data and then after that it should delay 20 seconds before it clicks a button on the page. How can this be achieved.

jindrich.bar avatar

Hello and thank you for your interest in this Actor!

Apologies for the delay in responding to your issue.

You can easily achieve this delay using the Promise constructor with setTimeout trick, as shown below:

log.info(+Date.now());
await new Promise(r => setTimeout(r, 5000));
log.info(+Date.now());

This code runs in the Page function and will log two timestamps that are 5000 milliseconds apart. You can adapt this approach to introduce a 20-second delay before clicking a button. Make sure to update the Actor timeouts appropriately.

I'll go ahead and close this issue, but feel free to open a new one if you need further assistance!