Actor picture

Crawler Puppeteer [DEPRECATED]


This actor is deprecated, please use apify/puppeteer-scraper instead.

Apify Crawler Puppeteer

How it works

Crawler Puppeteer is the most powerful crawler tool in our arsenal (aside from developing your own actors). It uses the Puppeteer library to programmatically control a headless Chrome browser and it can make it do almost anything. If using the Crawler does not cut it, Crawler Puppeteer is what you need.

The downside is that Puppeteer is a Node.js library, so knowledge of Node.js and its paradigms is expected when working with the Crawler Puppeteer.

If you need either a more performant, or a simpler tool, see the crawler-cheerio for unmatched performance, or crawler for a plain old JavaScript tool.


Input is provided via the pre-configured UI. See the tooltips for more info on the available options.

Page function

Page function is a single JavaScript function that enables the user to control the Crawler's operation, manipulate the crawled pages and extract data as needed. It is invoked with a context object containing the following properties:

const context = {
    input, // Unaltered original input as parsed from the UI
    env, // Contains information about the run such as actorId or runId
    customData, // Value of the 'Custom data' Crawler option.
    request, // Apify.Request object.
    response, // Response object holding the status code and headers.

    saveSnapshot, // Saves a screenshot and full HTML of the current page to the key value store.
    skipLinks, // Prevents enqueueing more links via Pseudo URLs on the current page.
    skipOutput, // Prevents saving the return value of the pageFunction to the default dataset.
    enqueuePage, // Adds a page to the request queue.
    jQuery, // A reference to the jQuery $ function (if injectJQuery was used).

    globalStore, // Represents an in memory store that can be used to share data across pageFunction invocations.
    requestList, // Reference to the run's default Apify.RequestList.
    requestQueue, // Reference to the run's default Apify.RequestQueue.
    dataset, // Reference to the run's default Apify.Dataset.
    keyValueStore, // Reference to the run's default Apify.KeyValueStore.
    log, // Reference to Apify.utils.log 
    underscoreJs, // A reference to the Underscore _ object (if injectUnderscore was used).


The following tables describe the context object in more detail.

Data structures:

Raw input as it was received from the UI, represented as a string for immutability. You can JSON.parse() it to get the values of individual configuration options.
A map of all the relevant environment variables that you may want to use. See the Apify.getEnv() function for a preview of the structure and full documentation.
Since the input UI is fixed, it does not support adding of other fields that may be needed for all specific use cases. If you need to pass arbitrary data to the crawler, use the Custom data input field and its contents will be available under the customData context key.
Apify uses a request object to represent metadata about the currently crawled page, such as its URL or the number of retries. See the Request class for a preview of the structure and full documentation.
response{status: number, headers: Object}
The HTTP response object is produced by Puppeteer. Currently, we only pass the HTTP status code and the response headers to the context.


A helper function that enables saving a snapshot of the current page's HTML and its screenshot into the default key value store. Each snapshot overwrites the previous one and the function's invocations will also be throttled if invoked more than once in 2 seconds, to prevent abuse. So make sure you don't call it for every single request. You can find the screenshot under the SNAPSHOT-SCREENSHOT key and the HTML under the SNAPSHOT-HTML key.
With each invocation of the pageFunction the crawler attempts to extract new URLs from the page using the Link selector and PseudoURLs provided in the input UI. If you want to prevent this behavior in certain cases, call the skipLinks function and no URLs will be added to the queue for the given page.
Since each return value of the pageFunction is saved to the default dataset, this provides a way of overriding that functionality. Just call skipOutput and the result of the current invocation will not be saved to the dataset.
To enqueue a specific URL manually instead of automatically by a combination of a Link selector and a Pseudo URL, use the enqueuePage function. It accepts a plain object as argument that needs to have the structure to construct a Request object. But frankly, you just need a URL: { url: 'https://www.example.com }
To make the DOM manipulation within the page easier, you may choose the injectJQuery option in the UI and all the crawled pages will have an instance of the jQuery library available. However, since we do not want to modify the page in any way, we don't inject it into the global $ object as you may be used to, but instead we make it available in context. Feel free to const $ = context.jQuery to get the familiar notation.

Class instances:

Global Store

globalStore represents an instance of a very simple in memory store that is not scoped to the individual pageFunction invocation. This enables you to easily share global data such as API responses, tokens and other. Since the stored data need to cross the from the Browser to the Node.js process, they cannot be any data, but always need to be JSON stringifiable. Therefore, you cannot store DOM objects, live class instances, functions etc. Only a JSON representation of the passed object will be stored, with all the relevant limitations.

MethodReturn Type
Retrieves a JSON serializable value from the global store using the provided key.
set(key:string, value:Object)Promise
Saves a JSON serializable value to the global store using the provided key.
Returns the current number of values in the global store.
Returns all the keys currently stored in the global store.


Ouput is a dataset containing extracted data for each scraped page.


For each of the scraped URLs, the dataset contains an object with results and some metadata. If you were scraping the HTML <title> of IANA it would look like this:

  "title": "Internet Assigned Numbers Authority",
  "#error": false,
  "#debug": {
    "url": "https://www.iana.org/",
    "method": "GET",
    "retryCount": 0,
    "errorMessages": null,
    "requestId": "e2Hd517QWfF4tVh"

The metadata are prefixed with a #. Soon you will be able to exclude the metadata from the results by providing an API flag.

  • Modified
  • Last run
  • Used8963 times