# Fast Scraper (`danielherman/fast-scraper`) Actor

Fast Scraper is a blazingly fast web scraper powered by Rust on the backend. It allows you to scrape static HTML pages extremely quickly while using only <128 MB of memory. With this scraper, you can maximize the efficiency of your credits on Apify.

- **URL**: https://apify.com/danielherman/fast-scraper.md
- **Developed by:** [Daniel Herman](https://apify.com/danielherman) (community)
- **Categories:** Developer tools
- **Security:** Full permissions
- **Stats:** 5 total users, 0 monthly users, 100.0% runs succeeded, 3 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## What is Fast Scraper?

Fast Scraper is a blazingly fast web scraper powered by Rust on the backend. It allows you to scrape static HTML pages extremely quickly while using only 128 MB of memory. With this scraper, you can maximize the efficiency of your credits on Apify.

## Why Choose Fast Scraper Over Cheerio?

Fast Scraper is blazing fast and will save you money. 🚀🚀🚀

Cheerio is powered by Node.js, meaning all the heavy lifting is done by JavaScript. JavaScript was never meant to be used as a scraper in the first place. It's similar to creating [a rollercoaster game in an Excel sheet](https://www.youtube.com/watch?v=IrVA1BBHFHw). 📉 📉 📉

### How much will scraping with Fast Scraper will cost you?

I did a benchmark where I scraped with max_concurency=50, 128 MB RAM and 1000 (52MB) csfd.cz pages the whole page and it cost me 0.026 USD and ran for 60 s. So it is very cheap. That would make roughly 38 500 (2GB) scraped websites for $1.

### How much cheaper and faster?

Here is a comparison performed on 1,000 csfd.cz pages. The entire static HTML was scraped and stored in storage. With Cheerio, using 128 MB of RAM, the process timed out after 3,600 seconds because the scraper actor required more RAM. On the other hand, Fast Scraper only needed an average of 33.2 MB of RAM and 0.88% CPU usage. It's extremely light and fast. At this moment, the bottleneck is probably Docker itself.
![](https://i.imgur.com/Vzw7Wph.png)

## Input parameters

### Example of an input

```
{
    "requests": [
        {
            "url": "https://www.scrapethissite.com/pages/simple/"
        },
        {
            "id": "forms",
            "url": "https://www.scrapethissite.com/pages/simple/",
            "extract": [
                {
                    "field_name": "extracted_html",
                    "selector": "#countries > div > div:nth-child(4) > div:nth-child(1)",
                    "extract_type": "HTML"
                }
            ]
        },
        {
            "id": "hockey",
            "url": "https://www.scrapethissite.com/pages/forms/",
            "extract": [
                {
                    "field_name": "year1",
                    "selector": "#hockey > div > table > tbody > tr:nth-child(2) > td.year",
                    "extract_type": "Text"
                },
                {
                    "field_name": "year2",
                    "selector": "#hockey > div > table > tbody > tr:nth-child(3) > td.year",
                    "extract_type": "Text"
                },
                {
                    "field_name": "class_name",
                    "selector": "#hockey > div > table > tbody > tr:nth-child(2) > td.year",
                    "extract_type": {
                        "Attribute": "class"
                    }
                }
            ]
        }
    ],
    "user_agent": "ApifyFastScraper/1.0",
    "force_cloud": false,
    "push_data_size": 500,
    "max_concurrency": 10,
    "max_request_retries": 3,
    "max_request_retry_timeout_ms": 10000,
    "request_retry_wait_ms": 5000
}
```

### Breaking Down the Configuration

1. Requests: You'll list multiple web pages to be scraped. Each web page entry (request) will need the following:
   - url: The URL of the web page to scrape.
   - id (optional): Unique identifier for the request.
   - extract (optional): List of fields to extract from the page. Each field will have a:
     - field_name: A name to identify the extracted data.
     - selector: CSS selector to pinpoint the HTML element containing the data.
     - extract_type: Type of extraction (Text, HTML, or an attribute like class).
2. Headers (optional): You can set additional HTTP headers globally or for individual requests. Global headers will be replaced with the request headers.
   - Example Global Header: { "Accept": "application/json" }
   - Example Request-specific Header: { "Accept-Language": "en-US" }
3. User-Agent (optional): Specify the user-agent string your scraper will use globally or for individual requests. Global user agent will be replaced with the request user agent. This helps mimic different web browsers.
4. Advanced Options (optional):
   - force_cloud: Whether to force the scraper to run in a cloud environment.
   - push_data_size: Max size of data chunks to push. Smaller value will ensure that you can offload the data into storage in smaller chunks.
   - max_concurrency: Max number of concurrent requests.
   - max_request_retries: Number of retries if a request fails.
   - max_request_retry_timeout_ms: Max time to wait before retrying a request.
   - request_retry_wait_ms: Waiting time between retries.

## Example of Output

```
[
    {
        "id": "hockey",
        "url": "https://www.scrapethissite.com/pages/forms/",
        "data": {
            "year2": "\n                            1990\n                        ",
            "class_name": "year",
            "year1": "\n                            1990\n                        "
        }
    },
    {
        "id": "9a2c62e1-79b0-4081-8db8-7d8cf549d4af",
        "url": "https://www.scrapethissite.com/pages/simple/",
        "data": {
            "full_html": "<!doctype html>\n<html lang=\"en\">the rest of html</html>"
        }
    },
    {
        "id": "forms",
        "url": "https://www.scrapethissite.com/pages/simple/",
        "data": {
            "extracted_html": "\n                        <h3 class=\"country-name\">\n                            <i class=\"flag-icon flag-icon-ad\"></i>\n                            Andorra\n                        </h3>\n                        <div class=\"country-info\">\n                            <strong>Capital:</strong> <span class=\"country-capital\">Andorra la Vella</span><br>\n                            <strong>Population:</strong> <span class=\"country-population\">84000</span><br>\n                            <strong>Area (km<sup>2</sup>):</strong> <span class=\"country-area\">468.0</span><br>\n                        </div>\n                    "
        }
    }
]
```

## Your feedback

I am always working on improving the performance of my Actors. So if you’ve got any technical feedback for Fast Scraper or simply found a bug, please create an issue on the Actor’s Issues tab in Apify Console.

# Actor input Schema

## `requests` (type: `array`):

Requests with given fields

## `proxy_settings` (type: `object`):

Select proxies to be used by your crawler. For most use cases we recommend the default Apify automatic proxy.

## `headers` (type: `object`):

Global headers to be used for all requests.

## `user_agent` (type: `string`):

Global user agent used for all requests.

## `force_cloud` (type: `boolean`):

Allows local runs to use cloud storage, mainly for testing. On Apify platform, this has no effect.

## `debug_log` (type: `boolean`):

Shows when each URL starts and ends scraping, with timings. Not recommended for larger runs as the log can get filled quickly.

## `push_data_size` (type: `integer`):

Buffers results into an array before pushing to a dataset to prevent overwhelming the Apify API. The default number is usually a good choice.

## `max_concurrency` (type: `integer`):

Sets the maximum concurrency (parallelism) for the crawl. Keep this to a reasonable level because this scraper can go really fast.

## `max_request_retries` (type: `integer`):

Sets the maximum number of retries for each request (URL).

## `max_request_retry_timeout_ms` (type: `integer`):

Sets the maximum timeout in milliseconds to retry a failed request.

## `request_retry_wait_ms` (type: `integer`):

Sets the wait time in milliseconds before retrying a failed request.

## Actor input object example

```json
{
  "requests": [
    {
      "url": "https://www.scrapethissite.com/pages/simple/"
    },
    {
      "id": "forms",
      "url": "https://www.scrapethissite.com/pages/simple/",
      "extract": [
        {
          "field_name": "extracted_html",
          "selector": "#countries > div > div:nth-child(4) > div:nth-child(1)",
          "extract_type": "HTML"
        }
      ]
    },
    {
      "id": "hockey",
      "url": "https://www.scrapethissite.com/pages/forms/",
      "extract": [
        {
          "field_name": "year1",
          "selector": "#hockey > div > table > tbody > tr:nth-child(2) > td.year",
          "extract_type": "Text"
        },
        {
          "field_name": "year2",
          "selector": "#hockey > div > table > tbody > tr:nth-child(3) > td.year",
          "extract_type": "Text"
        },
        {
          "field_name": "class_name",
          "selector": "#hockey > div > table > tbody > tr:nth-child(2) > td.year",
          "extract_type": {
            "Attribute": "class"
          }
        }
      ]
    }
  ],
  "proxy_settings": {
    "useApifyProxy": true
  },
  "user_agent": "ApifyFastScraper/1.0",
  "force_cloud": false,
  "debug_log": false,
  "push_data_size": 50,
  "max_concurrency": 10,
  "max_request_retries": 3,
  "max_request_retry_timeout_ms": 10000,
  "request_retry_wait_ms": 5000
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "requests": [
        {
            "url": "https://www.scrapethissite.com/pages/simple/"
        },
        {
            "id": "forms",
            "url": "https://www.scrapethissite.com/pages/simple/",
            "extract": [
                {
                    "field_name": "extracted_html",
                    "selector": "#countries > div > div:nth-child(4) > div:nth-child(1)",
                    "extract_type": "HTML"
                }
            ]
        },
        {
            "id": "hockey",
            "url": "https://www.scrapethissite.com/pages/forms/",
            "extract": [
                {
                    "field_name": "year1",
                    "selector": "#hockey > div > table > tbody > tr:nth-child(2) > td.year",
                    "extract_type": "Text"
                },
                {
                    "field_name": "year2",
                    "selector": "#hockey > div > table > tbody > tr:nth-child(3) > td.year",
                    "extract_type": "Text"
                },
                {
                    "field_name": "class_name",
                    "selector": "#hockey > div > table > tbody > tr:nth-child(2) > td.year",
                    "extract_type": {
                        "Attribute": "class"
                    }
                }
            ]
        }
    ],
    "proxy_settings": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("danielherman/fast-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "requests": [
        { "url": "https://www.scrapethissite.com/pages/simple/" },
        {
            "id": "forms",
            "url": "https://www.scrapethissite.com/pages/simple/",
            "extract": [{
                    "field_name": "extracted_html",
                    "selector": "#countries > div > div:nth-child(4) > div:nth-child(1)",
                    "extract_type": "HTML",
                }],
        },
        {
            "id": "hockey",
            "url": "https://www.scrapethissite.com/pages/forms/",
            "extract": [
                {
                    "field_name": "year1",
                    "selector": "#hockey > div > table > tbody > tr:nth-child(2) > td.year",
                    "extract_type": "Text",
                },
                {
                    "field_name": "year2",
                    "selector": "#hockey > div > table > tbody > tr:nth-child(3) > td.year",
                    "extract_type": "Text",
                },
                {
                    "field_name": "class_name",
                    "selector": "#hockey > div > table > tbody > tr:nth-child(2) > td.year",
                    "extract_type": { "Attribute": "class" },
                },
            ],
        },
    ],
    "proxy_settings": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("danielherman/fast-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "requests": [
    {
      "url": "https://www.scrapethissite.com/pages/simple/"
    },
    {
      "id": "forms",
      "url": "https://www.scrapethissite.com/pages/simple/",
      "extract": [
        {
          "field_name": "extracted_html",
          "selector": "#countries > div > div:nth-child(4) > div:nth-child(1)",
          "extract_type": "HTML"
        }
      ]
    },
    {
      "id": "hockey",
      "url": "https://www.scrapethissite.com/pages/forms/",
      "extract": [
        {
          "field_name": "year1",
          "selector": "#hockey > div > table > tbody > tr:nth-child(2) > td.year",
          "extract_type": "Text"
        },
        {
          "field_name": "year2",
          "selector": "#hockey > div > table > tbody > tr:nth-child(3) > td.year",
          "extract_type": "Text"
        },
        {
          "field_name": "class_name",
          "selector": "#hockey > div > table > tbody > tr:nth-child(2) > td.year",
          "extract_type": {
            "Attribute": "class"
          }
        }
      ]
    }
  ],
  "proxy_settings": {
    "useApifyProxy": true
  }
}' |
apify call danielherman/fast-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,danielherman/fast-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/FkKZODKPlAwtGeh9a/builds/FGaLrA0sVMW8tC1uk/openapi.json
