Installation &amp; setup | rust-crawler | Spatie       

 SPATIE  

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

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Rust-crawler](https://spatie.be/docs/rust-crawler/v1)  Installation &amp; setup

 Version   v1      

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

  Installation &amp; setup    
- [ 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)

 Installation &amp; setup
========================

###  On this page 

1. [ Use the library ](#content-use-the-library)
2. [ Install the CLI ](#content-install-the-cli)
3. [ Optional browser rendering ](#content-optional-browser-rendering)
4. [ Network access ](#content-network-access)

This package can be installed via Cargo. You'll need [Rust](https://rustup.rs/) 1.89 or later and a C compiler for bundled SQLite. PHP, Node and a system OpenSSL installation are not required.

Use the library
-----------------------------------------------------------------------------------------------------

Add the package and Tokio to your application's `Cargo.toml`:

```
[dependencies]
spatie-crawler = "0.2.0"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
```

The Cargo package is `spatie-crawler`; Rust imports use `spatie_crawler`. No additional setup is needed for HTTP crawling. Examples that use `async-trait`, `url`, `reqwest` or `scraper` directly mention the extra dependency you'll need.

Install the CLI
-----------------------------------------------------------------------------------------------------

You can also install the command-line tool:

```
cargo install spatie-crawler --version 0.2.0 --locked
rust-crawler crawl https://example.com --limit 20 --depth 2
```

Use `scrape` to extract content, or `map` to list URLs:

```
rust-crawler scrape https://example.com
rust-crawler map https://example.com
```

`crawl` and `scrape` emit JSONL events. `map` prints discovered URLs without fetching target pages by default. Add `--full` to traverse linked pages too. Diagnostics go to stderr. Run each subcommand with `--help` for its options.

Optional browser rendering
--------------------------------------------------------------------------------------------------------------------------------------

If you want to crawl JavaScript rendered pages, you'll need a JavaScript renderer. The crawler ships with `NativeBrowserRenderer` and `CloudflareRenderer`. You can also create your own by implementing `Renderer`. See [JavaScript rendering](advanced-usage/rendering-javascript) for details.

Network access
--------------------------------------------------------------------------------------------------

The built-in HTTP transport blocks private and loopback destinations by default. For a trusted local server, use `HttpFetcher::builder().allow_private_networks(true)` or `--allow-private` in the CLI. Read [network safety](configuring-the-crawler/configuring-requests#network-safety) before enabling this in an application.

Continue with [your first crawl](basic-usage/starting-your-first-crawl).

 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)
