Cheerio Scraper avatar

Cheerio Scraper

Try for free

No credit card required

Go to Store
Cheerio Scraper

Cheerio Scraper

apify/cheerio-scraper
Try for free

No credit card required

Crawls websites using raw HTTP requests, parses the HTML with the Cheerio library, and extracts data from the pages using a Node.js code. Supports both recursive crawling and lists of URLs. This actor is a high-performance alternative to apify/web-scraper for websites that do not require JavaScript.

You can access the Cheerio 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": "adDcXUJxW7dNodPKH"
6  },
7  "servers": [
8    {
9      "url": "https://api.apify.com/v2"
10    }
11  ],
12  "paths": {
13    "/acts/apify~cheerio-scraper/run-sync-get-dataset-items": {
14      "post": {
15        "operationId": "run-sync-get-dataset-items-apify-cheerio-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~cheerio-scraper/runs": {
50      "post": {
51        "operationId": "runs-sync-apify-cheerio-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~cheerio-scraper/run-sync": {
93      "post": {
94        "operationId": "run-sync-apify-cheerio-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": "A static list of URLs to scrape. <br><br>For details, see the <a href='https://apify.com/apify/cheerio-scraper#start-urls' target='_blank' rel='noopener'>Start URLs</a> section in the README.",
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          "keepUrlFragments": {
158            "title": "URL #fragments identify unique pages",
159            "type": "boolean",
160            "description": "Indicates that URL fragments (e.g. <code>http://example.com<b>#fragment</b></code>) should be included when checking whether a URL has already been visited or not. Typically, URL fragments are used for page navigation only and therefore they should be ignored, as they don't identify separate pages. However, some single-page websites use URL fragments to display different pages; in such cases, this option should be enabled.",
161            "default": false
162          },
163          "globs": {
164            "title": "Glob Patterns",
165            "type": "array",
166            "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.",
167            "default": [],
168            "items": {
169              "type": "object",
170              "required": [
171                "glob"
172              ],
173              "properties": {
174                "glob": {
175                  "type": "string",
176                  "title": "Glob of a web page"
177                }
178              }
179            }
180          },
181          "pseudoUrls": {
182            "title": "Pseudo-URLs",
183            "type": "array",
184            "description": "Specifies what kind of URLs found by the <b>Link selector</b> should be added to the request queue. A pseudo-URL is a URL with <b>regular expressions</b> enclosed in <code>[]</code> brackets, e.g. <code>http://www.example.com/[.*]</code>. <br><br>If <b>Pseudo-URLs</b> are omitted, the actor enqueues all links matched by the <b>Link selector</b>.<br><br>For details, see <a href='https://apify.com/apify/cheerio-scraper#pseudo-urls' target='_blank' rel='noopener'>Pseudo-URLs</a> in README.",
185            "default": [],
186            "items": {
187              "type": "object",
188              "required": [
189                "purl"
190              ],
191              "properties": {
192                "purl": {
193                  "type": "string",
194                  "title": "Pseudo-URL of a web page"
195                }
196              }
197            }
198          },
199          "excludes": {
200            "title": "Exclude Glob Patterns",
201            "type": "array",
202            "description": "Glob patterns to match links in the page that you want to exclude from being enqueued.",
203            "default": [],
204            "items": {
205              "type": "object",
206              "required": [
207                "glob"
208              ],
209              "properties": {
210                "glob": {
211                  "type": "string",
212                  "title": "Glob of a web page"
213                }
214              }
215            }
216          },
217          "linkSelector": {
218            "title": "Link selector",
219            "type": "string",
220            "description": "A CSS selector stating which links on the page (<code>&lt;a&gt;</code> elements with <code>href</code> attribute) shall be followed and added to the request queue. To filter the links added to the queue, use the <b>Pseudo-URLs</b> and/or <b>Glob patterns</b> field.<br><br>If the <b>Link selector</b> is empty, the page links are ignored.<br><br>For details, see the <a href='https://apify.com/apify/cheerio-scraper#link-selector' target='_blank' rel='noopener'>Link selector</a> in README."
221          },
222          "pageFunction": {
223            "title": "Page function",
224            "type": "string",
225            "description": "A JavaScript function that is executed for every page loaded server-side in Node.js 12. Use it to scrape data from the page, perform actions or add new URLs to the request queue.<br><br>For details, see <a href='https://apify.com/apify/cheerio-scraper#page-function' target='_blank' rel='noopener'>Page function</a> in README."
226          },
227          "proxyConfiguration": {
228            "title": "Proxy configuration",
229            "type": "object",
230            "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/cheerio-scraper#proxy-configuration' target='_blank' rel='noopener'>Proxy configuration</a> in README.",
231            "default": {
232              "useApifyProxy": true
233            }
234          },
235          "proxyRotation": {
236            "title": "Proxy rotation",
237            "enum": [
238              "RECOMMENDED",
239              "PER_REQUEST",
240              "UNTIL_FAILURE"
241            ],
242            "type": "string",
243            "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.",
244            "default": "RECOMMENDED"
245          },
246          "sessionPoolName": {
247            "title": "Session pool name",
248            "pattern": "[0-9A-z-]",
249            "minLength": 3,
250            "maxLength": 200,
251            "type": "string",
252            "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."
253          },
254          "initialCookies": {
255            "title": "Initial cookies",
256            "type": "array",
257            "description": "A JSON array with cookies that will be send with every HTTP request made by the Cheerio Scraper, in the format accepted by the <a href='https://www.npmjs.com/package/tough-cookie' target='_blank' rel='noopener noreferrer'>tough-cookie</a> NPM package. This option is useful for transferring a logged-in session from an external web browser. For details how to do this, read this <a href='https://help.apify.com/en/articles/1444249-log-in-to-website-by-transferring-cookies-from-web-browser-legacy' target='_blank' rel='noopener'>help article</a>.",
258            "default": []
259          },
260          "additionalMimeTypes": {
261            "title": "Additional MIME types",
262            "type": "array",
263            "description": "A JSON array specifying additional MIME content types of web pages to support. By default, Cheerio Scraper supports the <code>text/html</code> and <code>application/xhtml+xml</code> content types, and skips all other resources. For details, see <a href='https://apify.com/apify/cheerio-scraper#content-types' target='_blank' rel='noopener'>Content types</a> in README.",
264            "default": []
265          },
266          "suggestResponseEncoding": {
267            "title": "Suggest response encoding",
268            "type": "string",
269            "description": "The scraper automatically determines response encoding from the response headers. If the headers are invalid or information is missing, malformed responses may be produced. Use the Suggest response encoding option to provide a fall-back encoding to the Scraper for cases where it could not be determined."
270          },
271          "forceResponseEncoding": {
272            "title": "Force response encoding",
273            "type": "boolean",
274            "description": "If enabled, the suggested response encoding will be used even if a valid response encoding is provided by the target website. Use this only when you've inspected the responses thoroughly and are sure that they are the ones doing it wrong.",
275            "default": false
276          },
277          "ignoreSslErrors": {
278            "title": "Ignore SSL errors",
279            "type": "boolean",
280            "description": "If enabled, the scraper will ignore SSL/TLS certificate errors. Use at your own risk.",
281            "default": false
282          },
283          "preNavigationHooks": {
284            "title": "Pre-navigation hooks",
285            "type": "string",
286            "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 `requestAsBrowserOptions`, which are passed to the `requestAsBrowser()` function the crawler calls to navigate."
287          },
288          "postNavigationHooks": {
289            "title": "Post-navigation hooks",
290            "type": "string",
291            "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."
292          },
293          "maxRequestRetries": {
294            "title": "Max request retries",
295            "minimum": 0,
296            "type": "integer",
297            "description": "The maximum number of times the scraper will retry to load each web page on error, in case of a page load error or an exception thrown by the <b>Page function</b>.<br><br>If set to <code>0</code>, the page will be considered failed right after the first error.",
298            "default": 3
299          },
300          "maxPagesPerCrawl": {
301            "title": "Max pages per run",
302            "minimum": 0,
303            "type": "integer",
304            "description": "The maximum number of pages that the scraper will load. The scraper will stop when this limit is reached. It is always a good idea to set this limit in order to prevent excess platform usage for misconfigured scrapers. Note that the actual number of pages loaded might be slightly higher than this value.<br><br>If set to <code>0</code>, there is no limit.",
305            "default": 0
306          },
307          "maxResultsPerCrawl": {
308            "title": "Max result records",
309            "minimum": 0,
310            "type": "integer",
311            "description": "The maximum number of records that will be saved to the resulting dataset. The scraper will stop when this limit is reached. <br><br>If set to <code>0</code>, there is no limit.",
312            "default": 0
313          },
314          "maxCrawlingDepth": {
315            "title": "Max crawling depth",
316            "minimum": 0,
317            "type": "integer",
318            "description": "Specifies how many links away from the <b>Start URLs</b> the scraper will descend. This value is a safeguard against infinite crawling depths for misconfigured scrapers. Note that pages added using <code>context.enqueuePage()</code> in <b>Page function</b> are not subject to the maximum depth constraint. <br><br>If set to <code>0</code>, there is no limit.",
319            "default": 0
320          },
321          "maxConcurrency": {
322            "title": "Max concurrency",
323            "minimum": 1,
324            "type": "integer",
325            "description": "Specifies the maximum number of pages that can be processed by the scraper in parallel. The scraper automatically increases and decreases concurrency based on available system resources. This option enables you to set an upper limit, for example to reduce the load on a target web server.",
326            "default": 50
327          },
328          "pageLoadTimeoutSecs": {
329            "title": "Page load timeout",
330            "minimum": 1,
331            "type": "integer",
332            "description": "The maximum amount of time the scraper will wait for a web page to load, in seconds. If the web page does not load in this timeframe, it is considered to have failed and will be retried (subject to <b>Max page retries</b>), similarly as with other page load errors.",
333            "default": 60
334          },
335          "pageFunctionTimeoutSecs": {
336            "title": "Page function timeout",
337            "minimum": 1,
338            "type": "integer",
339            "description": "The maximum amount of time the scraper will wait for the <b>Page function</b> to execute, in seconds. It is always a good idea to set this limit, to ensure that unexpected behavior in page function will not get the scraper stuck.",
340            "default": 60
341          },
342          "debugLog": {
343            "title": "Enable debug log",
344            "type": "boolean",
345            "description": "If enabled, the actor log will include debug messages. Beware that this can be quite verbose. Use <code>context.log.debug('message')</code> to log your own debug messages from the <b>Page function</b>.",
346            "default": false
347          },
348          "customData": {
349            "title": "Custom data",
350            "type": "object",
351            "description": "A custom JSON object that is passed to the <b>Page function</b> as <code>context.customData</code>. This setting is useful when invoking the scraper via API, in order to pass some arbitrary parameters to your code.",
352            "default": {}
353          },
354          "datasetName": {
355            "title": "Dataset name",
356            "type": "string",
357            "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."
358          },
359          "keyValueStoreName": {
360            "title": "Key-value store name",
361            "type": "string",
362            "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."
363          },
364          "requestQueueName": {
365            "title": "Request queue name",
366            "type": "string",
367            "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."
368          }
369        }
370      },
371      "runsResponseSchema": {
372        "type": "object",
373        "properties": {
374          "data": {
375            "type": "object",
376            "properties": {
377              "id": {
378                "type": "string"
379              },
380              "actId": {
381                "type": "string"
382              },
383              "userId": {
384                "type": "string"
385              },
386              "startedAt": {
387                "type": "string",
388                "format": "date-time",
389                "example": "2025-01-08T00:00:00.000Z"
390              },
391              "finishedAt": {
392                "type": "string",
393                "format": "date-time",
394                "example": "2025-01-08T00:00:00.000Z"
395              },
396              "status": {
397                "type": "string",
398                "example": "READY"
399              },
400              "meta": {
401                "type": "object",
402                "properties": {
403                  "origin": {
404                    "type": "string",
405                    "example": "API"
406                  },
407                  "userAgent": {
408                    "type": "string"
409                  }
410                }
411              },
412              "stats": {
413                "type": "object",
414                "properties": {
415                  "inputBodyLen": {
416                    "type": "integer",
417                    "example": 2000
418                  },
419                  "rebootCount": {
420                    "type": "integer",
421                    "example": 0
422                  },
423                  "restartCount": {
424                    "type": "integer",
425                    "example": 0
426                  },
427                  "resurrectCount": {
428                    "type": "integer",
429                    "example": 0
430                  },
431                  "computeUnits": {
432                    "type": "integer",
433                    "example": 0
434                  }
435                }
436              },
437              "options": {
438                "type": "object",
439                "properties": {
440                  "build": {
441                    "type": "string",
442                    "example": "latest"
443                  },
444                  "timeoutSecs": {
445                    "type": "integer",
446                    "example": 300
447                  },
448                  "memoryMbytes": {
449                    "type": "integer",
450                    "example": 1024
451                  },
452                  "diskMbytes": {
453                    "type": "integer",
454                    "example": 2048
455                  }
456                }
457              },
458              "buildId": {
459                "type": "string"
460              },
461              "defaultKeyValueStoreId": {
462                "type": "string"
463              },
464              "defaultDatasetId": {
465                "type": "string"
466              },
467              "defaultRequestQueueId": {
468                "type": "string"
469              },
470              "buildNumber": {
471                "type": "string",
472                "example": "1.0.0"
473              },
474              "containerUrl": {
475                "type": "string"
476              },
477              "usage": {
478                "type": "object",
479                "properties": {
480                  "ACTOR_COMPUTE_UNITS": {
481                    "type": "integer",
482                    "example": 0
483                  },
484                  "DATASET_READS": {
485                    "type": "integer",
486                    "example": 0
487                  },
488                  "DATASET_WRITES": {
489                    "type": "integer",
490                    "example": 0
491                  },
492                  "KEY_VALUE_STORE_READS": {
493                    "type": "integer",
494                    "example": 0
495                  },
496                  "KEY_VALUE_STORE_WRITES": {
497                    "type": "integer",
498                    "example": 1
499                  },
500                  "KEY_VALUE_STORE_LISTS": {
501                    "type": "integer",
502                    "example": 0
503                  },
504                  "REQUEST_QUEUE_READS": {
505                    "type": "integer",
506                    "example": 0
507                  },
508                  "REQUEST_QUEUE_WRITES": {
509                    "type": "integer",
510                    "example": 0
511                  },
512                  "DATA_TRANSFER_INTERNAL_GBYTES": {
513                    "type": "integer",
514                    "example": 0
515                  },
516                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
517                    "type": "integer",
518                    "example": 0
519                  },
520                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
521                    "type": "integer",
522                    "example": 0
523                  },
524                  "PROXY_SERPS": {
525                    "type": "integer",
526                    "example": 0
527                  }
528                }
529              },
530              "usageTotalUsd": {
531                "type": "number",
532                "example": 0.00005
533              },
534              "usageUsd": {
535                "type": "object",
536                "properties": {
537                  "ACTOR_COMPUTE_UNITS": {
538                    "type": "integer",
539                    "example": 0
540                  },
541                  "DATASET_READS": {
542                    "type": "integer",
543                    "example": 0
544                  },
545                  "DATASET_WRITES": {
546                    "type": "integer",
547                    "example": 0
548                  },
549                  "KEY_VALUE_STORE_READS": {
550                    "type": "integer",
551                    "example": 0
552                  },
553                  "KEY_VALUE_STORE_WRITES": {
554                    "type": "number",
555                    "example": 0.00005
556                  },
557                  "KEY_VALUE_STORE_LISTS": {
558                    "type": "integer",
559                    "example": 0
560                  },
561                  "REQUEST_QUEUE_READS": {
562                    "type": "integer",
563                    "example": 0
564                  },
565                  "REQUEST_QUEUE_WRITES": {
566                    "type": "integer",
567                    "example": 0
568                  },
569                  "DATA_TRANSFER_INTERNAL_GBYTES": {
570                    "type": "integer",
571                    "example": 0
572                  },
573                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
574                    "type": "integer",
575                    "example": 0
576                  },
577                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
578                    "type": "integer",
579                    "example": 0
580                  },
581                  "PROXY_SERPS": {
582                    "type": "integer",
583                    "example": 0
584                  }
585                }
586              }
587            }
588          }
589        }
590      }
591    }
592  }
593}

Cheerio Scraper - HTML scraping tool 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 Cheerio 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

  • 599 monthly users

  • 120 bookmarks

  • >99% runs succeeded

  • 36 days response time

  • Created in Apr 2019

  • Modified 4 months ago