# Rust vs. Python for web scraping: why we rewrote everything

Why Spider rebuilt its scrapers in Rust, and a dated crawl of five documentation sites with the open source spider crate 2.53.9 that you can run again.

Canonical: https://spider.cloud/blog/rust-vs-python-web-scraping-why-we-rewrote-everything/

> Updated November 17, 2026. This report is indexed at [Spider Research](/research/). The section “A crawl you can repeat” has a dated run of the open source crate with its version, program and command. The February 2026 version of this post had benchmark tables that set the crate against a Python crawler. We never published the program or the page list behind them, so we removed them and every number that came from that benchmark.

Spider started as a Python project, built on Scrapy, BeautifulSoup and requests. That stack worked for small jobs and for demos, and it worked long enough to show us where it would stop.

This is why we rewrote the crawl engine in Rust. It also has one run of the open source crate on five sites that you can repeat, with the version, the command and a program.

## The Python wall

Our first scraper ran fine on one machine and on small sites. The trouble started with bigger jobs. We did not keep measurements from that period in a form we can publish, so this section and the next are our account of what happened, with no numbers.

### The global interpreter lock

In a standard CPython build, the global interpreter lock lets one thread run Python bytecode at a time. Our scraper spent most of its time waiting on the network, so asyncio or multiprocessing got us around the lock. Each has a price. Multiprocessing meant passing data between processes. With asyncio the waiting was cheap, but parsing HTML and transforming it still ran on one thread.

### Parsing

BeautifulSoup handles malformed HTML well and its API is pleasant. It is not fast. When we profiled the crawler, parsing and walking the tree took more CPU time than anything else we did, and that mattered more as the number of pages grew.

### Pauses

Garbage collection added latency we could not predict. Most requests were fine and a few were slow for no reason a user could see. We tried PyPy, Cython for the hot paths, connection pooling with aiohttp and worker pools that fork before they serve. Each one helped a little, and the pauses stayed.

## Why Rust

We built small crawlers in Go, C++ and Rust before we chose.

We found Go the simplest of the three to write. It still has a garbage collector, and unpredictable latency was the problem we were trying to leave behind. C++ had the speed, but our service parses untrusted HTML from any website for hours at a time, and we did not want to find its memory bugs in production.

Rust has no garbage collector. A value is freed when its last owner goes out of scope. In safe Rust the compiler rejects data races and use after free. Tokio gave us an async runtime that runs tasks across a pool of threads. The prototype convinced us, and we rewrote the engine.

## A crawl you can repeat, November 16, 2026

On November 16, 2026 we ran the open source [spider crate](https://github.com/spider-rs/spider) on five documentation sites and wrote down what you need to run it again. This is the crate on its own, on one machine. Our [guide to web scraping](/web-scraping/) covers the hosted API.

Create a package named `crawl` and add the crate at the version we ran:

```toml
[package]
name = "crawl"
version = "0.1.0"
edition = "2021"

[dependencies]
spider = "=2.53.9"
tokio = { version = "1", features = ["rt-multi-thread", "macros", "time"] }
```

The program crawls one site from a start URL, streams each page as it arrives and prints its status, size and URL:

```rust
use spider::tokio;
use spider::website::Website;
use std::time::{Duration, Instant};

#[tokio::main]
async fn main() {
    let start = std::env::args().nth(1).expect("usage: crawl <start url> <page limit>");
    let limit: u32 = std::env::args().nth(2).and_then(|n| n.parse().ok()).unwrap_or(200);

    let mut website = Website::new(&start);
    website
        .with_limit(limit)
        .with_respect_robots_txt(true)
        .with_subdomains(false)
        .with_request_timeout(Some(Duration::from_secs(30)));
    if let Ok(proxy) = std::env::var("SPIDER_PROXY_URL") {
        website.with_proxies(Some(vec![proxy]));
    }

    // Pages arrive on this channel while the crawl runs.
    let mut rx = website.subscribe(4096);
    let printer = tokio::spawn(async move {
        let mut pages = 0;
        while let Ok(page) = rx.recv().await {
            pages += 1;
            println!("{} {} {}", page.status_code.as_u16(), page.get_html_bytes_u8().len(), page.get_url());
        }
        pages
    });

    let t0 = Instant::now();
    website.crawl().await;
    let secs = t0.elapsed().as_secs_f64();
    website.unsubscribe();
    drop(website);
    let pages = printer.await.unwrap_or(0);
    println!("{pages} answers in {secs:.2} s");
}
```

Build it with `cargo build --release` and run one site per process. Every request in our run went through the [Spider proxy](/docs/api/proxy/) and not straight from our machine:

```bash
SPIDER_PROXY_URL="http://$SPIDER_API_KEY:country_code=us@proxy.spider.cloud:8888" \
  /usr/bin/time -l ./target/release/crawl https://htmx.org/ 200
```

We picked the sites before the run. They are the first five in a list of documentation sites whose robots.txt answered, allowed the start URL and asked for no crawl delay over five seconds. That list and the per URL records of the run are internal and not published.

| Site                                    | Distinct pages, status 200 | Crawl seconds | Pages a second | Peak memory |
| --------------------------------------- | -------------------------- | ------------- | -------------- | ----------- |
| [www.mkdocs.org](http://www.mkdocs.org) | 19                         | 1.67          | 11.4           | 23.6 MB     |
| htmx.org                                | 169                        | 4.74          | 35.7           | 34.0 MB     |
| squidfunk.github.io/mkdocs-material/    | 110                        | 2.69          | 40.9           | 40.7 MB     |
| docs.astral.sh/uv/                      | 84                         | 1.22          | 68.7           | 41.5 MB     |
| docs.pydantic.dev/latest/               | 200                        | 3.09          | 64.8           | 72.0 MB     |

Run of 2026-11-16, 16:20:53 to about 16:21:07 UTC. spider 2.53.9, rustc 1.97.1, release build, an Apple silicon Mac, limit 200. Crawl seconds time `website.crawl()` alone. Peak memory is the maximum resident size that `/usr/bin/time -l` reported for the whole process. A page in this table is a distinct URL that answered with status 200, and an address with and without its trailing slash counts once. We worked out pages a second from the unrounded seconds, so a figure can differ in the last digit from the two columns divided.

The program we ran also wrote each answer’s URL, status and size to a JSON line, and built the crate with its `remote_addr` feature to record where each answer came from. The version above prints the same fields as plain lines and leaves that feature out, so it is not the exact program we measured.

On three sites, mkdocs.org, mkdocs-material and uv, the crawl ended by itself before the limit of 200.

The program prints one line for every answer the crate returns, and its last line counts them all. That count is larger than the table’s. It includes answers with an error status and pages that answered under two spellings of one address, and we left both out. The crawl seconds cover those fetches too, so pages a second is on the low side. When you run this on your own site, count distinct URLs with status 200.

Memory is the number we would watch. The largest process here peaked at 72.0 MB with 200 pages through it. The speed column says less than it seems to. It includes each site’s own response time and the trip through the proxy, and all five are static sites.

This run does not compare the crate with a Python crawler, and it has no site that needs a browser. Each site ran once. Run the command on your own sites before you read anything general into it.

## How the crate hands you pages

The program above is a complete example. `website.subscribe()` returns a channel, and each page arrives on it while the crawl is still running, so your code works on page one before page 200 is fetched. You choose what to keep in memory after that.

The crate fetches over HTTP by default. Its `chrome` feature adds a browser for pages that build their content with JavaScript.

## What Rust buys a scraper

Having no garbage collector is the part we feel most. No collector runs in the background, so none can stop the process for a sweep.

Tokio tasks are cheaper than OS threads. A crawl can keep many requests in flight without a thread for each one.

The borrow checker rejects data races at compile time. A crawler has many tasks that read pages, pull links and update shared crawl state at once. In safe Rust, code with a data race in it does not compile.

Safe Rust also rejects use after free at compile time and checks slice bounds at run time, so a bad index panics and does not read past the buffer. We want that in a service that parses HTML from sites we do not control.

## What it cost us

The first months were slow. We fought the borrow checker, learned lifetimes, and learned when to share state and when to send it over a channel. We shipped less while we did.

Python’s HTML tooling felt ahead to us. We found nothing in Rust as forgiving as BeautifulSoup when we started, and we wrote more of our own extraction code than we would have in Python.

Hiring was harder for us. We hired systems programmers who knew C, C++ or Go and gave them time to learn.

Release builds are slow. Incremental builds are fine while we work, but CI waits on the compiler.

## What we would tell you

If you scrape a small site now and then, Python is fine. Scrapy is a good framework and BeautifulSoup does its job. You do not need Rust for a weekend project.

If the crawler is the product and has to run for hours, our experience is that Rust was worth the slow start. The run above is one small piece of evidence for the memory side of that, and it says nothing about latency.

The crate is open source under the MIT license. Run the crawl above on your own site from [github.com/spider-rs/spider](https://github.com/spider-rs/spider).

## Frequently asked questions

### How fast is the spider crate on a real site?

On November 16, 2026, spider 2.53.9 crawled five documentation sites on one Apple silicon Mac, one process per site, with a limit of 200 pages. Each site returned 19 to 200 distinct pages with status 200, in 1.22 to 4.74 seconds of crawl time. Each request went through the Spider proxy. The command, the per site table and a shorter version of the program are on this page.

### How much memory does a Rust crawler use?

In the same run, peak resident memory for the whole process was 23.6 MB on www\.mkdocs.org, the smallest crawl, and 72.0 MB on docs.pydantic.dev, 200 pages, as reported by /usr/bin/time -l.

### Is Rust faster than Python for web scraping?

We have no same day Python comparison to publish. An earlier version of this post carried February 2026 tables that set the crate against a Python crawler. We never published their program or page list, so we took them out. The November run measures the crate alone, so you can repeat it and compare it with your own Python crawler on the same sites.

### Does the spider crate obey robots.txt?

When you call with_respect_robots_txt(true), as the program on this page does, the crate reads each site's robots.txt and skips what it disallows.

## Sources

1. [Measured run, 2026-11-16, 16:20:53 to about 16:21:07 UTC: spider 2.53.9 on five documentation sites. The command is printed on this page with a shorter version of the program](https://github.com/spider-rs/spider)
2. [spider 2.53.9 on crates.io, MIT licensed](https://crates.io/crates/spider/2.53.9)
3. [Spider proxy documentation, the proxy URL format used in the run](https://spider.cloud/docs/api/proxy/)
4. [spider 2.53.9 API documentation, Website: subscribe, with_respect_robots_txt, with_limit and the chrome feature](https://docs.rs/spider/2.53.9/spider/website/struct.Website.html)
5. [The Rust Programming Language, ownership: when a value is dropped](https://doc.rust-lang.org/book/ch04-01-what-is-ownership.html)
6. [The Rust Programming Language, fearless concurrency: data races rejected at compile time](https://doc.rust-lang.org/book/ch16-00-concurrency.html)
7. [The Rust Programming Language, vectors: an index past the end panics](https://doc.rust-lang.org/book/ch08-01-vectors.html)
8. [Tokio tutorial, spawning: tasks and the multi-thread scheduler](https://tokio.rs/tokio/tutorial/spawning)
9. [Python glossary, global interpreter lock](https://docs.python.org/3/glossary.html#term-global-interpreter-lock)
