Introduction | rust-crawler | Spatie       

 SPATIE  

rust-crawler
============

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Rust-crawler](https://spatie.be/docs/rust-crawler/v1)  Introduction

 Version   v1      

 Other versions for crawler [v1](https://spatie.be/docs/rust-crawler/v1) 

  Introduction    
- [ Introduction ](https://spatie.be/docs/rust-crawler/v1/introduction)
- [ Installation &amp; setup ](https://spatie.be/docs/rust-crawler/v1/installation-setup)
- [ Support us ](https://spatie.be/docs/rust-crawler/v1/support-us)
- [ Questions and issues ](https://spatie.be/docs/rust-crawler/v1/questions-issues)
- [ Changelog ](https://spatie.be/docs/rust-crawler/v1/changelog)
- [ About us ](https://spatie.be/docs/rust-crawler/v1/about-us)

Basic usage
-----------

- [ Your first crawl ](https://spatie.be/docs/rust-crawler/v1/basic-usage/starting-your-first-crawl)
- [ Crawl responses ](https://spatie.be/docs/rust-crawler/v1/basic-usage/handling-crawl-responses)
- [ Using observers ](https://spatie.be/docs/rust-crawler/v1/basic-usage/using-observers)
- [ Collecting URLs ](https://spatie.be/docs/rust-crawler/v1/basic-usage/collecting-urls)
- [ Filtering URLs ](https://spatie.be/docs/rust-crawler/v1/basic-usage/filtering-urls)
- [ Testing ](https://spatie.be/docs/rust-crawler/v1/basic-usage/testing)
- [ Tracking progress ](https://spatie.be/docs/rust-crawler/v1/basic-usage/tracking-progress)

Configuring the crawler
-----------------------

- [ Concurrency &amp; throttling ](https://spatie.be/docs/rust-crawler/v1/configuring-the-crawler/crawl-behavior)
- [ Limits ](https://spatie.be/docs/rust-crawler/v1/configuring-the-crawler/setting-crawl-limits)
- [ Extracting resources ](https://spatie.be/docs/rust-crawler/v1/configuring-the-crawler/extracting-resources)
- [ Configuring requests ](https://spatie.be/docs/rust-crawler/v1/configuring-the-crawler/configuring-requests)
- [ Response filtering ](https://spatie.be/docs/rust-crawler/v1/configuring-the-crawler/handling-responses)
- [ Respecting robots.txt ](https://spatie.be/docs/rust-crawler/v1/configuring-the-crawler/respecting-robots-txt)

Advanced usage
--------------

- [ JavaScript rendering ](https://spatie.be/docs/rust-crawler/v1/advanced-usage/rendering-javascript)
- [ Custom link extraction ](https://spatie.be/docs/rust-crawler/v1/advanced-usage/extracting-custom-links)
- [ Custom request handlers ](https://spatie.be/docs/rust-crawler/v1/advanced-usage/custom-request-handlers)
- [ Crawling across requests ](https://spatie.be/docs/rust-crawler/v1/advanced-usage/crawling-across-requests)
- [ Custom crawl queue ](https://spatie.be/docs/rust-crawler/v1/advanced-usage/using-a-custom-crawl-queue)
- [ Graceful shutdown ](https://spatie.be/docs/rust-crawler/v1/advanced-usage/graceful-shutdown)

  Rust-crawler 
==============

 Crawl the web using Rust 

### Useful links

- [Repository](https://github.com/spatie/rust-crawler)
- [Discussions](https://github.com/spatie/rust-crawler/discussions)

Introduction
------------

###  On this page 

1. [ Coming from the PHP crawler ](#content-coming-from-the-php-crawler)

This package crawls websites concurrently using Rust and Tokio. Configure a crawler with a builder, then consume its async event stream. You can replace the URL policy, HTTP transport, link extractor, renderer, throttle, handlers and crawl store.

```
use spatie_crawler::{CrawlEvent, Crawler};

#[tokio::main]
async fn main() -> Result {
    let mut crawl = Crawler::builder("https://example.com")?
        .max_pages(100)
        .build()?
        .crawl();

    while let Some(event) = crawl.next().await {
        match event {
            CrawlEvent::Page { page, .. } => println!("{}: {}", page.url, page.status),
            CrawlEvent::Failed { url, error, .. } => eprintln!("{}: {error}", url.url),
            CrawlEvent::Finished { error: Some(error), .. } => return Err(error.into()),
            _ => {}
        }
    }
    Ok(())
}
```

The default crawl stays on the seed's hostname and respects robots rules. Responses arrive through a bounded stream, so you do not have to keep every page body in memory. The default URL queue still grows with discoveries; use a SQLite checkpoint for a disk-backed queue.

The library and CLI do not require PHP or Node. Optional JavaScript rendering controls an installed Chromium directly through CDP, or uses Cloudflare Browser Rendering. Native browser networking requires a trusted environment; read the [rendering security notes](advanced-usage/rendering-javascript) before enabling it.

Coming from the PHP crawler
-----------------------------------------------------------------------------------------------------------------------------------------

These docs follow the [PHP crawler's documentation](https://spatie.be/docs/crawler) structure. Rust uses owned builder values, traits and async streams rather than PHP inheritance and a blocking `start()` call.

Some defaults differ. Rust stays on the same host by default, uses a 30-second request timeout and retries twice. Trailing slashes and query ordering remain significant URL identities. The default HTTP transport cannot report curl-equivalent DNS, TCP, TLS or exact wire-first-byte timings. See [crawl responses](basic-usage/handling-crawl-responses) for the measurements it does provide.

This is a crawler library and command-line tool, not a hosted Firecrawl replacement. It includes Markdown extraction, metadata and sitemap-based mapping, but no HTTP server, AI extraction, cloud search or PDF/Office parsing.

Continue with [installation &amp; setup](installation-setup).

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
