Skip to content
项目

关于

用 Rust 编写的网页爬虫和抓取工具。Spider Cloud 背后的引擎。

数据与分析

这些数字如何统计

实测星标增长

24小时
+2
7天
+9
15天
+18
1个月
+54

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

Spider

Spider

A web crawler and scraper for Rust.

Crates.io version Crates.io downloads Documentation Build status

Docs · Examples · Spider Cloud · Discord

Spider crawls a site concurrently and hands you each page as it lands. It fetches over plain HTTP, and with the chrome feature it renders pages that need JavaScript in headless Chrome. On an Apple M1 Max it crawled 100,000 pages over loopback in 3.9 seconds. The benchmark has the setup.

Quickstart

cargo add spider
use spider::{tokio, website::Website};

#[tokio::main]
async fn main() {
    let mut website = Website::new("https://example.com");
    let mut rx = website.subscribe(0);

    let printer = tokio::spawn(async move {
        while let Ok(page) = rx.recv().await {
            println!("{}  {}", page.status_code, page.get_url());
        }
    });

    website.crawl().await;
    website.unsubscribe();
    let _ = printer.await;
}

Spider finds the links, fetches them concurrently and hands you each page the moment it lands. It stops when the site runs out or a limit you set is reached.

Scale it on Spider Cloud

A crawl outgrows one machine when it needs proxies and a fleet of browsers. Spider Cloud runs both, and moving to it takes one feature flag and a config.

[dependencies]
spider = { version = "2", features = ["spider_cloud"] }
use spider::configuration::{SpiderCloudConfig, SpiderCloudMode, SpiderCloudReturnFormat};

let cloud = SpiderCloudConfig::new("YOUR_API_KEY")
    .with_mode(SpiderCloudMode::Smart)
    .with_return_format(SpiderCloudReturnFormat::Markdown);

let mut website = Website::new("https://example.com")
    .with_spider_cloud_config(cloud)
    .build()
    .unwrap();

Smart mode sends each request through Spider's proxies. When that fetch fails, it hands the page to the scrape API, which can render it in a browser. Pages come back as markdown, ready for a model or a vector store.

Get an API key · No card required.

What runs where

The crate, on your machine Spider Cloud
Crawl, follow links, stream pages Yes Yes, same engine
Pages that need JavaScript Your own Chrome, with the chrome feature Browsers run on Spider's side
Proxies Bring your own In every request, exits in 199+ countries
Scale One machine, or your own spider_worker hosts Managed, nothing to run
Price Free, MIT licensed Pay as you go, with cost set by the site and its tier. Unlimited from $40 a month.

The open source and cloud comparison has the measured difference, and pricing has the rates.

Install

You want Run
Rust library cargo add spider
Command-line tool cargo install spider_cli
Node.js package npm i @spider-rs/spider-rs
Python package pip install spider_rs
MCP server cargo install spider_mcp

What it does

  • HTTP first, Chrome when a page needs it. With the smart feature, crawl_smart() fetches over plain HTTP and opens Chrome only for pages that build their content with JavaScript. See smart.rs.
  • Streaming. subscribe() delivers each page as it is fetched, on both the HTTP and the Chrome path. See subscribe.rs.
  • Limits you set. Page count, depth, a budget per path, delay, concurrency, retries, robots.txt, and allow and deny lists that take regex patterns with the regex feature.
  • Scheduled and cached crawls. Cron schedules, HTTP caching to disk or memory, sitemap discovery and WARC 1.1 output.
  • More than one machine. The decentralized feature moves fetching to spider_worker processes on other hosts.
  • Chrome control. Screenshots, request interception, ad blocking and remote Chrome over CHROME_URL.
  • Your own proxies. with_proxies takes a list of proxy URLs for local crawls, with SOCKS5 under the socks feature.
let mut website = Website::new("https://example.com")
    .with_limit(500)                        // stop after 500 pages
    .with_depth(10)                         // how far to follow links
    .with_concurrency_limit(Some(50))       // requests in flight
    .with_delay(250)                        // pause between requests, in ms
    .with_respect_robots_txt(true)
    .build()
    .unwrap();

Every option is in the Configuration docs, and every feature flag is in the features reference.

For AI agents

Spider Cloud hosts an MCP server at https://mcp.spider.cloud/mcp. It signs in with OAuth on the first tool call. To run an MCP server on your own machine, install the spider_mcp crate. Coding agents working in this repository start at AGENTS.md.

Learn more

Contributing

Pull requests are welcome. CONTRIBUTING.md covers setup and tests.

License

MIT

探索相关项目

加载中…