Puppeteer Scraper avatar

Puppeteer Scraper

Try for free

No credit card required

Go to Store
Puppeteer Scraper

Puppeteer Scraper

apify/puppeteer-scraper
Try for free

No credit card required

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.

You can access the Puppeteer Scraper programmatically from your own applications by using the Apify API. You can choose the language preference from below. To use the Apify API, you’ll need an Apify account and your API token, found in Integrations settings in Apify Console.

1{
2  "openapi": "3.0.1",
3  "info": {
4    "version": "3.0",
5    "x-build-id": "hB12AV7CSfXaybCLd"
6  },
7  "servers": [
8    {
9      "url": "https://api.apify.com/v2"
10    }
11  ],
12  "paths": {
13    "/acts/apify~puppeteer-scraper/run-sync-get-dataset-items": {
14      "post": {
15        "operationId": "run-sync-get-dataset-items-apify-puppeteer-scraper",
16        "x-openai-isConsequential": false,
17        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
18        "tags": [
19          "Run Actor"
20        ],
21        "requestBody": {
22          "required": true,
23          "content": {
24            "application/json": {
25              "schema": {
26                "$ref": "#/components/schemas/inputSchema"
27              }
28            }
29          }
30        },
31        "parameters": [
32          {
33            "name": "token",
34            "in": "query",
35            "required": true,
36            "schema": {
37              "type": "string"
38            },
39            "description": "Enter your Apify token here"
40          }
41        ],
42        "responses": {
43          "200": {
44            "description": "OK"
45          }
46        }
47      }
48    },
49    "/acts/apify~puppeteer-scraper/runs": {
50      "post": {
51        "operationId": "runs-sync-apify-puppeteer-scraper",
52        "x-openai-isConsequential": false,
53        "summary": "Executes an Actor and returns information about the initiated run in response.",
54        "tags": [
55          "Run Actor"
56        ],
57        "requestBody": {
58          "required": true,
59          "content": {
60            "application/json": {
61              "schema": {
62                "$ref": "#/components/schemas/inputSchema"
63              }
64            }
65          }
66        },
67        "parameters": [
68          {
69            "name": "token",
70            "in": "query",
71            "required": true,
72            "schema": {
73              "type": "string"
74            },
75            "description": "Enter your Apify token here"
76          }
77        ],
78        "responses": {
79          "200": {
80            "description": "OK",
81            "content": {
82              "application/json": {
83                "schema": {
84                  "$ref": "#/components/schemas/runsResponseSchema"
85                }
86              }
87            }
88          }
89        }
90      }
91    },
92    "/acts/apify~puppeteer-scraper/run-sync": {
93      "post": {
94        "operationId": "run-sync-apify-puppeteer-scraper",
95        "x-openai-isConsequential": false,
96        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
97        "tags": [
98          "Run Actor"
99        ],
100        "requestBody": {
101          "required": true,
102          "content": {
103            "application/json": {
104              "schema": {
105                "$ref": "#/components/schemas/inputSchema"
106              }
107            }
108          }
109        },
110        "parameters": [
111          {
112            "name": "token",
113            "in": "query",
114            "required": true,
115            "schema": {
116              "type": "string"
117            },
118            "description": "Enter your Apify token here"
119          }
120        ],
121        "responses": {
122          "200": {
123            "description": "OK"
124          }
125        }
126      }
127    }
128  },
129  "components": {
130    "schemas": {
131      "inputSchema": {
132        "type": "object",
133        "required": [
134          "startUrls",
135          "pageFunction",
136          "proxyConfiguration"
137        ],
138        "properties": {
139          "startUrls": {
140            "title": "Start URLs",
141            "type": "array",
142            "description": "URLs to start with",
143            "items": {
144              "type": "object",
145              "required": [
146                "url"
147              ],
148              "properties": {
149                "url": {
150                  "type": "string",
151                  "title": "URL of a web page",
152                  "format": "uri"
153                }
154              }
155            }
156          },
157          "globs": {
158            "title": "Glob Patterns",
159            "type": "array",
160            "description": "Glob patterns to match links in the page that you want to enqueue. Combine with Link selector to tell the scraper where to find links. Omitting the Glob patterns will cause the scraper to enqueue all links matched by the Link selector.",
161            "default": [],
162            "items": {
163              "type": "object",
164              "required": [
165                "glob"
166              ],
167              "properties": {
168                "glob": {
169                  "type": "string",
170                  "title": "Glob of a web page"
171                }
172              }
173            }
174          },
175          "pseudoUrls": {
176            "title": "Pseudo-URLs",
177            "type": "array",
178            "description": "Pseudo-URLs to match links in the page that you want to enqueue. Combine with Link selector to tell the scraper where to find links. Omitting the Pseudo-URLs will cause the scraper to enqueue all links matched by the Link selector.",
179            "default": [],
180            "items": {
181              "type": "object",
182              "required": [
183                "purl"
184              ],
185              "properties": {
186                "purl": {
187                  "type": "string",
188                  "title": "Pseudo-URL of a web page"
189                }
190              }
191            }
192          },
193          "excludes": {
194            "title": "Exclude Glob Patterns",
195            "type": "array",
196            "description": "Glob patterns to match links in the page that you want to exclude from being enqueued.",
197            "default": [],
198            "items": {
199              "type": "object",
200              "required": [
201                "glob"
202              ],
203              "properties": {
204                "glob": {
205                  "type": "string",
206                  "title": "Glob of a web page"
207                }
208              }
209            }
210          },
211          "linkSelector": {
212            "title": "Link selector",
213            "type": "string",
214            "description": "CSS selector matching elements with 'href' attributes that should be enqueued. To enqueue urls from <code><div class=\"my-class\" href=...></code> tags, you would enter <strong>div.my-class</strong>. Leave empty to ignore all links."
215          },
216          "clickableElementsSelector": {
217            "title": "Clickable elements selector",
218            "type": "string",
219            "description": "For pages where simple 'href' links are not available, this attribute allows you to specify a CSS selector matching elements that the scraper will mouse click after the page function finishes. Any triggered requests, navigations or open tabs will be intercepted and the target URLs will be filtered using Pseudo URLs and/or Glob patterns and subsequently added to the request queue. Leave empty to prevent the scraper from clicking in the page. Using this setting will have a performance impact."
220          },
221          "keepUrlFragments": {
222            "title": "Keep URL fragments",
223            "type": "boolean",
224            "description": "URL fragments (the parts of URL after a <code>#</code>) are not considered when the scraper determines whether a URL has already been visited. This means that when adding URLs such as <code>https://example.com/#foo</code> and <code>https://example.com/#bar</code>, only the first will be visited. Turn this option on to tell the scraper to visit both.",
225            "default": false
226          },
227          "pageFunction": {
228            "title": "Page function",
229            "type": "string",
230            "description": "Function executed for each request"
231          },
232          "proxyConfiguration": {
233            "title": "Proxy configuration",
234            "type": "object",
235            "description": "Specifies proxy servers that will be used by the scraper in order to hide its origin.<br><br>For details, see <a href='https://apify.com/apify/puppeteer-scraper#proxy-configuration' target='_blank' rel='noopener'>Proxy configuration</a> in README.",
236            "default": {
237              "useApifyProxy": true
238            }
239          },
240          "proxyRotation": {
241            "title": "Proxy rotation",
242            "enum": [
243              "RECOMMENDED",
244              "PER_REQUEST",
245              "UNTIL_FAILURE"
246            ],
247            "type": "string",
248            "description": "This property indicates the strategy of proxy rotation and can only be used in conjunction with Apify Proxy. The recommended setting automatically picks the best proxies from your available pool and rotates them evenly, discarding proxies that become blocked or unresponsive. If this strategy does not work for you for any reason, you may configure the scraper to either use a new proxy for each request, or to use one proxy as long as possible, until the proxy fails. IMPORTANT: This setting will only use your available Apify Proxy pool, so if you don't have enough proxies for a given task, no rotation setting will produce satisfactory results.",
249            "default": "RECOMMENDED"
250          },
251          "sessionPoolName": {
252            "title": "Session pool name",
253            "pattern": "[0-9A-z-]",
254            "minLength": 3,
255            "maxLength": 200,
256            "type": "string",
257            "description": "<b>Use only english alphanumeric characters dashes and underscores.</b> A session is a representation of a user. It has it's own IP and cookies which are then used together to emulate a real user. Usage of the sessions is controlled by the Proxy rotation option. By providing a session pool name, you enable sharing of those sessions across multiple actor runs. This is very useful when you need specific cookies for accessing the websites or when a lot of your proxies are already blocked. Instead of trying randomly, a list of working sessions will be saved and a new actor run can reuse those sessions. Note that the IP lock on sessions expires after 24 hours, unless the session is used again in that window."
258          },
259          "initialCookies": {
260            "title": "Initial cookies",
261            "type": "array",
262            "description": "The provided cookies will be pre-set to all pages the scraper opens.",
263            "default": []
264          },
265          "useChrome": {
266            "title": "Use Chrome",
267            "type": "boolean",
268            "description": "The scraper will use a real Chrome browser instead of a Chromium masking as Chrome. Using this option may help with bypassing certain anti-scraping protections, but risks that the scraper will be unstable or not work at all.",
269            "default": false
270          },
271          "headless": {
272            "title": "Run browsers in headless mode",
273            "type": "boolean",
274            "description": "By default, browsers run in headless mode. You can toggle this off to run them in headful mode, which can help with certain rare anti-scraping protections but is slower and more costly.",
275            "default": true
276          },
277          "ignoreSslErrors": {
278            "title": "Ignore SSL errors",
279            "type": "boolean",
280            "description": "Scraper will ignore SSL certificate errors.",
281            "default": false
282          },
283          "ignoreCorsAndCsp": {
284            "title": "Ignore CORS and CSP",
285            "type": "boolean",
286            "description": "Scraper will ignore CSP (content security policy) and CORS (cross origin resource sharing) settings of visited pages and requested domains. This enables you to freely use XHR/Fetch to make HTTP requests from the scraper.",
287            "default": false
288          },
289          "downloadMedia": {
290            "title": "Download media",
291            "type": "boolean",
292            "description": "Scraper will download media such as images, fonts, videos and sounds. Disabling this may speed up the scrape, but certain websites could stop working correctly.",
293            "default": true
294          },
295          "downloadCss": {
296            "title": "Download CSS",
297            "type": "boolean",
298            "description": "Scraper will download CSS stylesheets. Disabling this may speed up the scrape, but certain websites could stop working correctly.",
299            "default": true
300          },
301          "maxRequestRetries": {
302            "title": "Max request retries",
303            "minimum": 0,
304            "type": "integer",
305            "description": "Maximum number of times the request for the page will be retried in case of an error. Setting it to 0 means that the request will be attempted once and will not be retried if it fails.",
306            "default": 3
307          },
308          "maxPagesPerCrawl": {
309            "title": "Max pages per run",
310            "minimum": 0,
311            "type": "integer",
312            "description": "Maximum number of pages that the scraper will open. 0 means unlimited.",
313            "default": 0
314          },
315          "maxResultsPerCrawl": {
316            "title": "Max result records",
317            "minimum": 0,
318            "type": "integer",
319            "description": "Maximum number of results that will be saved to dataset. The scraper will terminate afterwards. 0 means unlimited.",
320            "default": 0
321          },
322          "maxCrawlingDepth": {
323            "title": "Max crawling depth",
324            "minimum": 0,
325            "type": "integer",
326            "description": "Defines how many links away from the StartURLs will the scraper descend. 0 means unlimited.",
327            "default": 0
328          },
329          "maxConcurrency": {
330            "title": "Max concurrency",
331            "minimum": 1,
332            "type": "integer",
333            "description": "Defines how many pages can be processed by the scraper in parallel. The scraper automatically increases and decreases concurrency based on available system resources. Use this option to set a hard limit.",
334            "default": 50
335          },
336          "pageLoadTimeoutSecs": {
337            "title": "Page load timeout",
338            "minimum": 1,
339            "type": "integer",
340            "description": "Maximum time the scraper will allow a web page to load in seconds.",
341            "default": 60
342          },
343          "pageFunctionTimeoutSecs": {
344            "title": "Page function timeout",
345            "minimum": 1,
346            "type": "integer",
347            "description": "Maximum time the scraper will wait for the page function to execute in seconds.",
348            "default": 60
349          },
350          "waitUntil": {
351            "title": "Navigation wait until",
352            "type": "array",
353            "description": "The scraper will wait until the selected events are triggered in the page before executing the page function. Available events are <code>domcontentloaded</code>, <code>load</code>, <code>networkidle2</code> and <code>networkidle0</code>. <a href=\"https://pptr.dev/#?product=Puppeteer&show=api-pagegotourl-options\" target=\"_blank\">See Puppeteer docs</a>.",
354            "default": [
355              "networkidle2"
356            ]
357          },
358          "preNavigationHooks": {
359            "title": "Pre-navigation hooks",
360            "type": "string",
361            "description": "Async functions that are sequentially evaluated before the navigation. Good for setting additional cookies or browser properties before navigation. The function accepts two parameters, `crawlingContext` and `gotoOptions`, which are passed to the `page.goto()` function the crawler calls to navigate."
362          },
363          "postNavigationHooks": {
364            "title": "Post-navigation hooks",
365            "type": "string",
366            "description": "Async functions that are sequentially evaluated after the navigation. Good for checking if the navigation was successful. The function accepts `crawlingContext` as the only parameter."
367          },
368          "closeCookieModals": {
369            "title": "Dismiss cookie modals",
370            "type": "boolean",
371            "description": "Using the [I don't care about cookies](https://addons.mozilla.org/en-US/firefox/addon/i-dont-care-about-cookies/) browser extension. When on, the crawler will automatically try to dismiss cookie consent modals. This can be useful when crawling European websites that show cookie consent modals.",
372            "default": false
373          },
374          "maxScrollHeightPixels": {
375            "title": "Maximum scrolling distance in pixels",
376            "type": "integer",
377            "description": "The crawler will scroll down the page until all content is loaded or the maximum scrolling distance is reached. Setting this to `0` disables scrolling altogether.",
378            "default": 5000
379          },
380          "debugLog": {
381            "title": "Debug log",
382            "type": "boolean",
383            "description": "Debug messages will be included in the log. Use <code>context.log.debug('message')</code> to log your own debug messages.",
384            "default": false
385          },
386          "browserLog": {
387            "title": "Browser log",
388            "type": "boolean",
389            "description": "Console messages from the Browser will be included in the log. This may result in the log being flooded by error messages, warnings and other messages of little value, especially with high concurrency.",
390            "default": false
391          },
392          "customData": {
393            "title": "Custom data",
394            "type": "object",
395            "description": "This object will be available on pageFunction's context as customData.",
396            "default": {}
397          },
398          "datasetName": {
399            "title": "Dataset name",
400            "type": "string",
401            "description": "Name or ID of the dataset that will be used for storing results. If left empty, the default dataset of the run will be used."
402          },
403          "keyValueStoreName": {
404            "title": "Key-value store name",
405            "type": "string",
406            "description": "Name or ID of the key-value store that will be used for storing records. If left empty, the default key-value store of the run will be used."
407          },
408          "requestQueueName": {
409            "title": "Request queue name",
410            "type": "string",
411            "description": "Name of the request queue that will be used for storing requests. If left empty, the default request queue of the run will be used."
412          }
413        }
414      },
415      "runsResponseSchema": {
416        "type": "object",
417        "properties": {
418          "data": {
419            "type": "object",
420            "properties": {
421              "id": {
422                "type": "string"
423              },
424              "actId": {
425                "type": "string"
426              },
427              "userId": {
428                "type": "string"
429              },
430              "startedAt": {
431                "type": "string",
432                "format": "date-time",
433                "example": "2025-01-08T00:00:00.000Z"
434              },
435              "finishedAt": {
436                "type": "string",
437                "format": "date-time",
438                "example": "2025-01-08T00:00:00.000Z"
439              },
440              "status": {
441                "type": "string",
442                "example": "READY"
443              },
444              "meta": {
445                "type": "object",
446                "properties": {
447                  "origin": {
448                    "type": "string",
449                    "example": "API"
450                  },
451                  "userAgent": {
452                    "type": "string"
453                  }
454                }
455              },
456              "stats": {
457                "type": "object",
458                "properties": {
459                  "inputBodyLen": {
460                    "type": "integer",
461                    "example": 2000
462                  },
463                  "rebootCount": {
464                    "type": "integer",
465                    "example": 0
466                  },
467                  "restartCount": {
468                    "type": "integer",
469                    "example": 0
470                  },
471                  "resurrectCount": {
472                    "type": "integer",
473                    "example": 0
474                  },
475                  "computeUnits": {
476                    "type": "integer",
477                    "example": 0
478                  }
479                }
480              },
481              "options": {
482                "type": "object",
483                "properties": {
484                  "build": {
485                    "type": "string",
486                    "example": "latest"
487                  },
488                  "timeoutSecs": {
489                    "type": "integer",
490                    "example": 300
491                  },
492                  "memoryMbytes": {
493                    "type": "integer",
494                    "example": 1024
495                  },
496                  "diskMbytes": {
497                    "type": "integer",
498                    "example": 2048
499                  }
500                }
501              },
502              "buildId": {
503                "type": "string"
504              },
505              "defaultKeyValueStoreId": {
506                "type": "string"
507              },
508              "defaultDatasetId": {
509                "type": "string"
510              },
511              "defaultRequestQueueId": {
512                "type": "string"
513              },
514              "buildNumber": {
515                "type": "string",
516                "example": "1.0.0"
517              },
518              "containerUrl": {
519                "type": "string"
520              },
521              "usage": {
522                "type": "object",
523                "properties": {
524                  "ACTOR_COMPUTE_UNITS": {
525                    "type": "integer",
526                    "example": 0
527                  },
528                  "DATASET_READS": {
529                    "type": "integer",
530                    "example": 0
531                  },
532                  "DATASET_WRITES": {
533                    "type": "integer",
534                    "example": 0
535                  },
536                  "KEY_VALUE_STORE_READS": {
537                    "type": "integer",
538                    "example": 0
539                  },
540                  "KEY_VALUE_STORE_WRITES": {
541                    "type": "integer",
542                    "example": 1
543                  },
544                  "KEY_VALUE_STORE_LISTS": {
545                    "type": "integer",
546                    "example": 0
547                  },
548                  "REQUEST_QUEUE_READS": {
549                    "type": "integer",
550                    "example": 0
551                  },
552                  "REQUEST_QUEUE_WRITES": {
553                    "type": "integer",
554                    "example": 0
555                  },
556                  "DATA_TRANSFER_INTERNAL_GBYTES": {
557                    "type": "integer",
558                    "example": 0
559                  },
560                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
561                    "type": "integer",
562                    "example": 0
563                  },
564                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
565                    "type": "integer",
566                    "example": 0
567                  },
568                  "PROXY_SERPS": {
569                    "type": "integer",
570                    "example": 0
571                  }
572                }
573              },
574              "usageTotalUsd": {
575                "type": "number",
576                "example": 0.00005
577              },
578              "usageUsd": {
579                "type": "object",
580                "properties": {
581                  "ACTOR_COMPUTE_UNITS": {
582                    "type": "integer",
583                    "example": 0
584                  },
585                  "DATASET_READS": {
586                    "type": "integer",
587                    "example": 0
588                  },
589                  "DATASET_WRITES": {
590                    "type": "integer",
591                    "example": 0
592                  },
593                  "KEY_VALUE_STORE_READS": {
594                    "type": "integer",
595                    "example": 0
596                  },
597                  "KEY_VALUE_STORE_WRITES": {
598                    "type": "number",
599                    "example": 0.00005
600                  },
601                  "KEY_VALUE_STORE_LISTS": {
602                    "type": "integer",
603                    "example": 0
604                  },
605                  "REQUEST_QUEUE_READS": {
606                    "type": "integer",
607                    "example": 0
608                  },
609                  "REQUEST_QUEUE_WRITES": {
610                    "type": "integer",
611                    "example": 0
612                  },
613                  "DATA_TRANSFER_INTERNAL_GBYTES": {
614                    "type": "integer",
615                    "example": 0
616                  },
617                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
618                    "type": "integer",
619                    "example": 0
620                  },
621                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
622                    "type": "integer",
623                    "example": 0
624                  },
625                  "PROXY_SERPS": {
626                    "type": "integer",
627                    "example": 0
628                  }
629                }
630              }
631            }
632          }
633        }
634      }
635    }
636  }
637}

Puppeteer Scraper for headless Chrome OpenAPI definition

OpenAPI is a standard for designing and describing RESTful APIs, allowing developers to define API structure, endpoints, and data formats in a machine-readable way. It simplifies API development, integration, and documentation.

OpenAPI is effective when used with AI agents and GPTs by standardizing how these systems interact with various APIs, for reliable integrations and efficient communication.

By defining machine-readable API specifications, OpenAPI allows AI models like GPTs to understand and use varied data sources, improving accuracy. This accelerates development, reduces errors, and provides context-aware responses, making OpenAPI a core component for AI applications.

You can download the OpenAPI definitions for Puppeteer Scraper from the options below:

If you’d like to learn more about how OpenAPI powers GPTs, read our blog post.

You can also check out our other API clients:

Developer
Maintained by Apify

Actor Metrics

  • 445 monthly users

  • 96 bookmarks

  • >99% runs succeeded

  • 33 days response time

  • Created in Apr 2019

  • Modified 8 months ago