speedCrawl
by ADEEL-308
README.md
# speedCrawl
**Free, local, open-source web scraper, search engine & crawler for AI agents — URL to clean Markdown, web search without API keys, site crawling, and structured data extraction. No cloud, no account, no vendor lock-in.**
[](https://github.com/ADEEL-308/speedCrawl/actions/workflows/tests.yml)
[](LICENSE)
[](https://www.python.org/)
[](https://modelcontextprotocol.io/)
speedCrawl is a **self-hosted web research toolkit** built for LLMs and agents. It turns any web page into **LLM-ready Markdown**, searches the web through a **local SearXNG instance (Google/Bing/DuckDuckGo)** with a **Bing fallback**, crawls websites responsibly, and extracts **structured JSON** using a JSON Schema — with **zero API keys required**.
It is a free, lightweight alternative to hosted scraping APIs such as Firecrawl: everything runs on your own machine, so your research data never leaves it.
## Why speedCrawl?
- **No API key, no billing** — no hosted scraping service, no per-page charges.
- **Privacy-first & self-hosted** — searches via your own SearXNG Docker container; pages fetched locally.
- **Multiple interfaces** — MCP server for AI agents, CLI with `--json`, and a FastAPI HTTP API.
- **LLM-agnostic extraction** — works with free models; Mode A needs no model at all.
- **JavaScript support** — optional headless Chromium via Playwright for React/Vue/Next.js pages.
- **Polite crawling** — depth/page caps, regex filters, `robots.txt` support and configurable delay.
- **Built-in caching** — SQLite cache with TTL so repeated research never re-hits a site.
## Table of contents
- [Install](#install)
- [1. Scrape — URL to Markdown](#1-scrape--url-to-markdown)
- [2. Search — web search without an API key](#2-search--web-search-without-an-api-key)
- [2a. Federated search (M1)](#2a-federated-search-m1)
- [2b. Search quality benchmark (M0)](#2b-search-quality-benchmark-m0)
- [3. Crawl — website crawler](#3-crawl--website-crawler)
- [4. Extract — structured JSON extraction](#4-extract--structured-json-extraction)
- [5. JavaScript rendering](#5-javascript-rendering)
- [6. MCP server for AI agents](#6-mcp-server-for-ai-agents)
- [7. HTTP API](#7-http-api)
- [8. Python API](#8-python-api)
- [Cache](#cache)
- [Configuration](#configuration)
- [Tests](#tests)
- [Comparison](#comparison)
- [License](#license)
## Install
```bash
git clone https://github.com/ADEEL-308/speedCrawl.git
cd speedCrawl
python3 -m venv .venv
./.venv/bin/pip install -r requirements.txt
# Optional: MCP server (Claude Code, OpenCode, Cursor, VS Code)
./.venv/bin/pip install -r requirements-mcp.txt
# Optional: JavaScript rendering for SPA / JS-heavy pages
./.venv/bin/pip install -r requirements-js.txt
./.venv/bin/python -m playwright install chromium
# Optional: private SearXNG for local, key-free web search
docker compose up -d
```
All dependencies are free and open-source: `requests`, `trafilatura`, `beautifulsoup4`, `fastapi`, `uvicorn`, `mcp`, `playwright`, and SearXNG.
## 1. Scrape — URL to Markdown
```bash
./.venv/bin/python -m speedcrawl scrape https://example.com
./.venv/bin/python -m speedcrawl scrape example.com -o article.md --json
./.venv/bin/python -m speedcrawl scrape https://example.com --refresh --robots
```
Returns `title`, `author`, `published_at`, `description`, clean `markdown`, plain `text`, `word_count`, timing and cache status. `--raw` keeps the original HTML.
## 2. Search — web search without an API key
`auto` tries the local **SearXNG** instance first (Google engine preferred), then falls back to **Bing**, so search works even without Docker.
```bash
./.venv/bin/python -m speedcrawl search "python trafilatura documentation" --limit 5
./.venv/bin/python -m speedcrawl search "topic" --provider bing
./.venv/bin/python -m speedcrawl search "topic" --provider duckduckgo
./.venv/bin/python -m speedcrawl search "topic" --engines google
./.venv/bin/python -m speedcrawl search "trafilatura" --scrape --scrape-limit 2 --json
```
With `--scrape`, the top results also carry the full page Markdown — ideal for **agentic web research** and RAG pipelines.
## 2a. Federated search (M1)
Federated search combines free, keyless sources — **GitHub, Stack Exchange and Wikipedia** — with a local relevance engine. It is opt-in so the existing search path stays unchanged:
```bash
./.venv/bin/python -m speedcrawl search "trafilatura documentation" --federated --limit 5 --show-provider-status
./.venv/bin/python -m speedcrawl search "RAG evaluation" --federated --providers github,stackexchange --format json
```
Pipeline: deterministic intent routing → parallel provider calls → URL canonicalization and deduplication → reciprocal rank fusion (`k=60`) + BM25 (`k1=1.2`, `b=0.75`) with percentile normalization (0.65 / 0.35 weights) → exact-phrase boost → diversity reranking (MMR `λ=0.8`, soft 3-per-domain cap). Provider health uses a circuit breaker (`HEALTHY → DEGRADED → OPEN → HALF_OPEN`), and provider responses are cached in SQLite with per-provider TTLs. One failed provider returns partial results, never an exception.
New interfaces: MCP tool `search_federated`, API `POST /search/federated`. All original tools and `/search` remain intact.
## 2b. Search quality benchmark (M0)
```bash
PYTHONPATH=. ./.venv/bin/python -m benchmarks.search.run_benchmark --input tests/search/fixtures/baseline/federated_m1.jsonl --system federated_m1 --output benchmark-results/m0-federated.json
```
50 frozen queries (10 in each of 5 categories), human-assigned 0–3 grades, offline fixtures and metrics: Precision@5, Recall@10, MRR, nDCG@10, duplicate rate, provider latency and failure rate. Reports land in `benchmark-results/`.
| System | P@5 | Recall@10 | MRR | nDCG@10 |
|---|---:|---:|---:|---:|
| Existing SearXNG/Bing search | 0.000 | 0.000 | 0.000 | 0.000 |
| Federated M1 | 0.024 | 0.090 | 0.077 | 0.075 |
These are measured results from this machine, not claims about other services. Scores remain low: free structured sources have narrow coverage, and some live calls hit provider rate limits. See `benchmarks/search/README.md`.
## 3. Crawl — website crawler
```bash
./.venv/bin/python -m speedcrawl crawl https://trafilatura.readthedocs.io/en/latest/ \
--max-pages 3 --depth 1 --delay 0.5 --out-dir ./pages
```
Flags: `--include REGEX`, `--exclude REGEX`, `--external`, `--depth N`, `--max-pages N`, `--delay SEC`, `--raw`, `--robots`, `--js`. Non-HTML files and duplicates are skipped.
## 4. Extract — structured JSON extraction
**Mode A (default) — no model, no key, no setup.** speedCrawl returns Markdown + your JSON Schema + an instruction; the LLM already calling it produces the final JSON. Works with any model, including free ones.
```bash
./.venv/bin/python -m speedcrawl extract https://example.com \
--schema '{"type":"object","properties":{"domain":{"type":"string"}},"required":["domain"]}'
```
**Mode B (optional) — a separate LLM does the extraction.**
| Provider | Environment variables |
|---|---|
| `none` (default) | Mode A — no model needed |
| `ollama` | `SPEEDCRAWL_OLLAMA_URL`, `SPEEDCRAWL_OLLAMA_MODEL` |
| `opencode` | `SPEEDCRAWL_OPENCODE_URL`, `SPEEDCRAWL_OPENCODE_MODEL` |
| `openai-compatible` | `SPEEDCRAWL_OPENAI_BASE_URL`, `SPEEDCRAWL_OPENAI_MODEL`, `SPEEDCRAWL_OPENAI_API_KEY` |
| `anthropic` | `SPEEDCRAWL_ANTHROPIC_API_KEY`, `SPEEDCRAWL_ANTHROPIC_MODEL` |
```bash
SPEEDCRAWL_LLM_PROVIDER=ollama ./.venv/bin/python -m speedcrawl extract URL --schema ./schema.json
```
## 5. JavaScript rendering
Add `--js` to `scrape`, `crawl` or `extract` to execute page scripts in headless Chromium before extraction. Useful for React/Vue/Next.js pages, lazy-loaded articles and infinite-scroll sites.
```bash
./.venv/bin/python -m speedcrawl scrape https://quotes.toscrape.com/js/ --js --wait-ms 1500
./.venv/bin/python -m speedcrawl crawl https://example.com --js --depth 1 --scroll
```
Options: `--wait-until {domcontentloaded,load,networkidle,commit}`, `--wait-ms N`, `--scroll`. Rendered and plain results are cached separately.
## 6. MCP server for AI agents
Four native tools: `scrape_page`, `search_web`, `crawl_site`, `extract_data`.
**OpenCode** — add to your `opencode.json`:
```json
{
"mcp": {
"speedcrawl": {
"type": "local",
"command": ["<absolute-path>/speedCrawl/.venv/bin/python", "-m", "speedcrawl.mcp_server"],
"environment": { "PYTHONPATH": "<absolute-path>/speedCrawl" },
"enabled": true
}
}
}
```
**Claude Code:**
```bash
claude mcp add speedcrawl \
--env PYTHONPATH=/absolute/path/to/speedCrawl \
-- /absolute/path/to/speedCrawl/.venv/bin/python -m speedcrawl.mcp_server
```
Other MCP clients: point their config at the same stdio command. Restart your client after updating so it reloads the tool definitions.
## 7. HTTP API
```bash
./.venv/bin/python -m speedcrawl serve --port 8765
curl -X POST http://127.0.0.1:8765/extract -H 'Content-Type: application/json' \
-d '{"url":"https://example.com","schema":{"type":"object","properties":{"domain":{"type":"string"}}}}'
```
Endpoints: `/health`, `/scrape`, `/search`, `/crawl`, `/extract` (POST + GET variants). All responses: `{"success": true, "data": {...}}`. Interactive docs: `http://127.0.0.1:8765/docs`.
## 8. Python API
```python
from speedcrawl.scraper import scrape
from speedcrawl.search import search
from speedcrawl.crawler import crawl
from speedcrawl.extract import extract
print(scrape("https://example.com").markdown)
print(search("python scraper", limit=5).results)
print(crawl("https://example.com", max_pages=3).pages)
print(extract("https://example.com", {"type": "object", "properties": {"title": {"type": "string"}}}).to_dict())
```
## Cache
All commands share `~/.speedcrawl/cache.sqlite3` (override with `SPEEDCRAWL_CACHE`); `--no-cache` bypasses it.
```bash
./.venv/bin/python -m speedcrawl cache path
./.venv/bin/python -m speedcrawl cache clear
```
## Configuration
| Variable | Purpose |
|---|---|
| `SPEEDCRAWL_CACHE` | Cache database path |
| `SPEEDCRAWL_SEARCH_PROVIDER` | `auto`, `searxng`, `duckduckgo`, `bing` |
| `SPEEDCRAWL_SEARXNG_URL` | SearXNG base URL (default `http://127.0.0.1:8080`) |
| `SPEEDCRAWL_SEARXNG_ENGINES` | Preferred SearXNG engine(s), default `google` |
| `SPEEDCRAWL_LLM_PROVIDER` | `none`, `ollama`, `opencode`, `openai-compatible`, `anthropic` |
## Tests
```bash
./.venv/bin/python -m unittest discover -s tests -v
```
72 offline tests — HTTP, browser, LLM and provider calls are mocked.
## Comparison
| Feature | speedCrawl | Hosted scraping APIs |
|---|---|---|
| API key required | No | Yes |
| Runs locally / self-hosted | Yes | No |
| Search without API key | Yes (SearXNG + Bing) | Usually no |
| Website crawler | Yes | Often paid extra |
| Structured JSON extraction | Yes (any LLM, or none) | Model-locked |
| JavaScript rendering | Optional, local Chromium | Included but billed |
| Data leaves your machine | No | Yes |
| Cost | Free (MIT) | Usage-based |
## Design
| Piece | Implementation |
|---|---|
| Fetch / extract content | `requests` + retry, `trafilatura` + `BeautifulSoup` fallback |
| Search | Legacy SearXNG/Bing path + opt-in federated GitHub/StackExchange/Wikipedia with local RRF+BM25 ranking |
| Crawl | BFS, depth/page caps, regex filters, `robots.txt`, polite delay |
| Structured extraction | Mode A (calling LLM) + optional Ollama / OpenCode / OpenAI-compatible / Anthropic |
| JavaScript rendering | Playwright + headless Chromium in a worker thread |
| Agent integration | MCP server (stdio) + CLI JSON + FastAPI |
| Cache | `sqlite3` (stdlib), TTL + refresh |
## Roadmap
- [x] `scrape`, `search`, `crawl`
- [x] LLM-agnostic `extract` (Mode A default, optional Mode B providers)
- [x] MCP server for Claude Code / OpenCode / any MCP client
- [x] Playwright renderer for JavaScript-heavy sites
- [x] M0 search benchmark: 50 frozen queries and offline metrics
- [x] M1 federated search MVP: GitHub, Stack Exchange, Wikipedia
- [ ] More search engines & result ranking options
- [ ] E-commerce / job-board extraction recipes
## License
MIT — free to use, modify and redistribute. Built on trafilatura, requests, beautifulsoup4, fastapi, uvicorn, mcp, playwright and SearXNG.
**Keywords:** web scraping, web crawler, search API, URL to Markdown, LLM tools, MCP server, SearXNG, Playwright, structured data extraction, self-hosted, no API key, Firecrawl alternative, AI web research, Python scraper.