Skip to main content

Universal web collection engine โ€” extract, monitor, and search any website through Cloudflare

Project description

๐ŸŒพ Harvest โ€” Open-Source AI Web Scraper with Cloudflare Bypass & LLM Extraction

GitHub Stars

Free, open-source alternative to Firecrawl, Crawl4AI, and ScrapeGraphAI. Extract structured data from any website โ€” bypasses Cloudflare, uses LLM for natural-language extraction, and runs as an MCP server for AI agents. No API keys required, no cloud, 100% local.

Logo

Python Scrapling License GitHub release BTC ETH USDT SOL


Demo

# One command โ€” full page content
harvest scrape https://news.ycombinator.com
# Structured data โ€” no CSS needed
harvest llm-extract https://books.toscrape.com \
  --prompt "Get all book titles and prices"
{
  "url": "https://books.toscrape.com",
  "title": "Books to Scrape",
  "extracted": {
    "books": [
      {"title": "A Light in the Attic", "price": "ยฃ51.77"},
      {"title": "Tipping the Velvet", "price": "ยฃ53.74"}
    ]
  }
}

Why Harvest?

Why Harvest?

Benchmark: Harvest vs Crawl4AI vs Firecrawl

Feature Harvest Crawl4AI (72kโ˜…) Firecrawl
Semantic Cache โœ… Meaning-based, 50-70% token savings โŒ URL-only โŒ
Self-Healing Parsers โœ… Auto-regenerate broken selectors via LLM โŒ โŒ
Structural Diff โœ… DOM change detection + summary โŒ โŒ
Cloudflare/Turnstile bypass โœ… Built-in (Scrapling) โš ๏ธ Basic โœ…
LLM extraction (natural language) โœ… Any OpenAI API โœ… โœ…
MCP server (AI agent integration) โœ… โŒ โŒ
Preprocessing modes (4 modes) โœ… full/economy/hybrid/auto โŒ โŒ
Anti-fingerprinting (24 UAs) โœ… โŒ โœ…
One command, zero config โœ… โœ… โœ…
Marketplace templates (Ozon/WB) โœ… โŒ โŒ
Price Free Free $50/mo
Keywords: web scraping python, llm web scraper, cloudflare bypass scraper, mcp server scraping, open source alternative to Firecrawl, scrape without API key, python web scraping library

๐Ÿง  Semantic Cache (v0.6.2)

Save 50-70% LLM tokens on repeated queries. Cache works by meaning, not exact text.

# Enable semantic cache
harvest llm-extract https://shop.com --prompt "Get all prices" --semantic-cache

# Check cache stats
harvest cache-stats

How it works:

  1. First query: "Extract all product prices" โ†’ LLM โ†’ result cached
  2. Second query: "Get product prices" โ†’ cache hit (0 tokens used)
  3. Third query: "Find prices on page" โ†’ cache hit (0 tokens used)

Invalidation: Cache auto-invalidates when HTML changes (content hash).


๐Ÿ”ง Self-Healing Parsers (v0.6.2)

Never lose data to website changes. Auto-regenerate broken CSS selectors via LLM.

# Enable self-healing
harvest llm-extract https://shop.com --prompt "Get prices" --self-healing

How it works:

  1. Test existing selectors on new HTML
  2. If broken โ†’ send old/new HTML to LLM
  3. LLM generates new selectors
  4. Validate new selectors โ†’ save if working

History: All selector changes stored in ~/.harvest/self_healing/


๐Ÿ“Š Structural Diff (v0.6.2)

See exactly what changed on any website. Like git diff for web pages.

# Capture snapshot
harvest snapshot https://shop.com --name v1.0

# Later: compare with current
harvest diff https://shop.com v1.0 latest

Output:

๐Ÿ“Š Structural Diff for https://shop.com
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ†• Added:
  โ€ข Block "Recommendations" (after description)
  โ€ข Field "Delivery" (in sidebar)

โŒ Removed:
  โ€ข Field "SKU" (was in header)

๐Ÿ”„ Changed:
  โ€ข Price: <span class="price"> โ†’ <div class="price-container">

๐Ÿ’ก Recommendation:
  Update selector: .price โ†’ .price-container .price-value


๐Ÿค– Script Generator (v0.6.2)

Zero-token scraping. Analyzes a page with LLM once to discover CSS selectors, then generates a standalone Python script that extracts the same data forever โ€” 0 LLM tokens at runtime.

Like ScrapeGraphAI's script generation, but you keep the script.

# Analyze a page and generate a scraper (one-time LLM cost)
harvest generate https://shop.com --fields title price image

# Generated script is fully standalone โ€” no Harvest needed
./scrape_generated.py https://shop.com/page/123

# Batch mode
./scrape_generated.py urls.txt --csv prices.csv

Why it matters:

Before (LLM every time) After (one LLM, zero forever)
harvest llm-extract โ€” 2K tokens/run harvest generate โ€” one-time 4K tokens
1000 runs = 2M tokens ($0.30-2.00) 1000 runs = $0.00
Needs LLM endpoint running Pure Python + Scrapling, runs anywhere
Slow (LLM latency each call) Fast (Scrapling HTTP + BeautifulSoup)

What's generated:

  • Self-contained Python script with hardcoded CSS selectors
  • Pagination support (if detected)
  • CSV/JSON export
  • Batch URL processing from file
  • Retry logic + random delays for anti-detection
  • Stealth headers

Features

Capability Harvest Browse AI ($50/mo) Octoparse ($80/mo) ScrapingBee ($50/mo)
Cloudflare bypass โœ… โœ… โŒ โœ…
Anti-fingerprinting (24 UAs, WebGL, Canvas) โœ… โŒ โŒ โŒ
JS rendered pages โœ… โŒ โœ… โœ…
LLM extraction (describe, not code) โœ… โŒ โŒ โŒ
Structured extraction (CSS) โœ… โœ… โœ… โŒ
Change monitoring + diffs โœ… โœ… โŒ โŒ
Full site crawling โœ… โŒ โœ… โŒ
Contact/email collection โœ… โŒ โœ… โŒ
MCP server (AI agent interface) โœ… โŒ โŒ โŒ
Rate limiting + caching โœ… โŒ โŒ โŒ
Price Free $50/mo $80/mo $50/mo

New in v0.6.2:

Feature Harvest Crawl4AI Firecrawl
Script Generator โœ… Generate standalone scripts (0 tokens) โŒ โŒ

Quick Start

pip install scrapling aiohttp
git clone https://github.com/zad111ak-ai/harvest
cd harvest

# Install CLI
pip install -e .

# Scrape any page
harvest scrape https://news.ycombinator.com

# Extract by CSS
harvest extract https://books.toscrape.com \
  --schema '{"title": "h3 a", "price": ".price_color"}'

# Extract by AI (describe in plain language!)
harvest llm-extract https://books.toscrape.com \
  --prompt "Get all book titles, prices, and availability"

# Monitor for changes
harvest monitor https://example.com/pricing

# Crawl entire site
harvest crawl https://docs.example.com --max-pages 100

# Find contacts
harvest contacts https://company.com

# Batch from file
harvest batch urls.txt --concurrency 10

# Discover all URLs on a site
harvest map https://docs.example.com

# Check installation health
harvest doctor

Preprocessing Modes (v0.6.2)

Harvest has 4 preprocessing modes for different use cases. Default is full โ€” safe, zero data loss.

Quick comparison

Mode Token savings Data loss risk Best for
full 0-40% โŒ None Default. Debugging. When you need every byte.
economy 70-90% โš ๏ธ Low LLM extraction. RAG systems. Embeddings.
hybrid 85-95% โš ๏ธ Low AI agents. Structured extraction pipelines.
auto varies โš ๏ธ Low Smart detection. Picks best mode per page.

Usage

# Default: full mode (safe, preserves everything)
harvest scrape https://example.com

# Economy: save tokens for LLM processing
harvest scrape https://shop.com --mode economy

# Hybrid: economy + extraction context for AI
harvest llm-extract https://shop.com --mode hybrid --prompt "Get all products"

# Auto: smart detection (picks best mode automatically)
harvest scrape https://any-site.com --mode auto

What each mode does

full (default)

  • Removes: scripts, styles, comments, hidden elements
  • Keeps: ALL content, navigation, footer, sidebar, links
  • Output: Markdown with all text and links preserved
  • Risk: None. You get everything the page had.

economy

  • Removes: nav, footer, sidebar, ads, boilerplate, duplicate content
  • Keeps: main content only, links as [text](url)
  • For catalogs: keeps first 3 items, collapses rest ("...and 47 more")
  • Output: Clean Markdown, 70-90% smaller than raw
  • Risk: May remove some content on unusual page layouts
  • Safety: Falls back to full if it removes >85% on non-catalog pages

hybrid

  • Everything economy does, PLUS:
  • Adds extraction context header for LLMs
  • Tells LLM: "This is a CATALOG with 20 items. Here are 3 examples. Extract all."
  • Output: Economy Markdown + extraction instructions
  • Risk: Same as economy. Context header adds ~200 chars.

auto

  • Detects page type (article/catalog/mixed)
  • Articles โ†’ uses economy mode
  • Catalogs โ†’ uses hybrid mode
  • Falls back gracefully if detection fails
  • Risk: Same as underlying mode chosen

โš ๏ธ Honest trade-offs

What you lose with economy/hybrid:

  • Navigation menus, footers, sidebars (usually useless)
  • Exact HTML structure (CSS classes, tag hierarchy)
  • Text inside images (infographics, screenshots)
  • Content hidden behind JS clicks ("Show phone number")

What you keep:

  • All text content
  • All links as standard [text](url) Markdown
  • All prices, titles, descriptions
  • Semantic structure (headings, paragraphs, lists)

When to use full:

  • Debugging what the page actually contains
  • Downstream parsers that need raw HTML structure
  • Sites where economy mode removes too much
  • When you're not sure what you need

When to use economy or hybrid:

  • Sending content to LLM for extraction
  • Building RAG systems or embeddings
  • Processing many pages (cost savings compound)
  • Catalog/listing pages with repetitive structure

โœจ LLM Extraction (v0.5.0)

The killer feature. No other free scraping tool has this.

Instead of writing CSS selectors, just describe what you want:

# Get product data
harvest llm-extract https://shop.example.com/products \
  --prompt "Find all product names, prices, and ratings"

# Get article metadata
harvest llm-extract https://blog.example.com \
  --prompt "Extract the author, publish date, and main topics"

# Custom JSON schema
harvest llm-extract https://example.com \
  --prompt "Get company name, address, and phone" \
  --schema '{"company": "string", "address": "string", "phone": "string"}'

How it works:

  1. Harvest scrapes the page through Cloudflare
  2. Content is sent to a local LLM (via OmniRoute, Ollama, or any OpenAI-compatible API)
  3. LLM returns structured JSON โ€” no regex, no CSS, no pain

Zero external API costs. Works with any local LLM endpoint. Configure:

# ~/.harvest/config.yaml
llm:
  base_url: "http://localhost:3000/v1"  # OmniRoute, Ollama, etc.
  model: "auto/best-chat"
  api_key: "sk-..."

All Commands

Command Description
harvest scrape <url> Page content as Markdown/text/HTML
harvest extract <url> --schema JSON Structured data by CSS selectors
harvest llm-extract <url> --prompt TEXT Structured data by AI description
harvest llm-extract <url> --prompt TEXT --semantic-cache AI extraction with token caching
harvest llm-extract <url> --prompt TEXT --self-healing AI extraction with auto-healing selectors
harvest monitor <url> Track page changes with diffs
harvest crawl <url> --max-pages N Crawl entire site
harvest map <url> Discover all URLs on a site (sitemap + links)
harvest contacts <url> Emails, social links, phones
harvest batch <file> --concurrency N Process many URLs
`harvest pipeline "scrape URL extract SCHEMA"`
harvest screenshot <url> Full-page screenshot
harvest search <query> Web search
harvest doctor Check installation health
harvest snapshot <url> Capture DOM structure for diff
harvest diff <url> <old> <new> Compare DOM snapshots
harvest cache-stats Semantic cache statistics
harvest generate <url> --fields F1 F2 Generate standalone scraping script (0 token cost)
harvest-mcp MCP server for AI agents

Python API

import asyncio
from harvest import Scraper, SchemaExtractor, LLMExtractor

async def main():
    # Basic scrape
    scraper = Scraper()
    result = await scraper.scrape("https://example.com")
    print(result["content"])

    # CSS extraction
    extractor = SchemaExtractor()
    data = await extractor.extract("https://shop.com", {
        "price": ".price",
        "title": "h1",
    })
    print(data["extracted"])

    # LLM extraction (describe what you want)
    llm = LLMExtractor(model="auto/best-chat")
    result = await llm.extract(
        url="https://news.ycombinator.com",
        description="Get top 10 story titles and points",
    )
    print(result["extracted"])

asyncio.run(main())

MCP Server for AI Agents

Harvest exposes everything via Model Context Protocol (MCP) โ€” works with Claude, Cursor, Hermes, and any MCP client.

# Install
pip install -e ".[mcp]"

# Test
harvest-mcp --version

# Register with Hermes
hermes mcp add harvest --command 'harvest-mcp'

Available MCP tools:

Tool Description
scrape(url, extraction?) Scrape a page
extract(url, schema) CSS-based extraction
llm_extract(url, prompt, schema?) AI-based extraction
batch(urls, concurrency?) Process multiple URLs
contacts(url, depth?) Collect contacts
crawl(url, max_pages?) Crawl a site
monitor(url) Check for changes
status() System info

Configuration

# ~/.harvest/config.yaml
proxy:
  url: ""                        # Leave blank = direct
  use_scrapling: true            # Scrapling built-in proxy

scraper:
  rate_limit: "5/1s"             # 5 req/sec
  concurrency: 3                 # Parallel requests
  timeout: 30                    # Seconds
  retries: 3

llm:                             # For llm-extract command
  base_url: "http://localhost:3000/v1"
  model: "auto/best-chat"
  api_key: "sk-..."

export:
  default_format: json

All fields are optional. Works out of the box with zero config.


How It Works

  1. Scrapling launches a headless Chromium with anti-detection fingerprints
  2. Cloudflare/anti-bot challenges are solved automatically
  3. Content is extracted from the rendered DOM
  4. LLM parses content into structured JSON (when using llm-extract)
  5. Snapshots saved locally for change detection

Bypasses Cloudflare JS challenges and Interstitial pages. Turnstile checkbox (behavioral biometrics) may still block โ€” marked as "needs manual action."


Requirements

  • Python 3.10+
  • Scrapling 0.4.9+
  • Chromium (auto-downloaded)
  • Optional: any OpenAI-compatible LLM endpoint for llm-extract

Install in 10 seconds:

pip install scrapling aiohttp
pip install -e .

v0.6.2 Changelog

  • ๐Ÿค– Script Generator โ€” analyze once, scrape forever. harvest generate <url> --fields title price
  • ๐Ÿง  Semantic Cache โ€” meaning-based response cache (saves 50-70% LLM tokens)
  • ๐Ÿ”ง Self-Healing Parsers โ€” auto-regenerate broken CSS selectors via LLM
  • ๐Ÿ“Š Structural Diff โ€” DOM structure change detection with human-readable summary
  • ๐Ÿ“ธ harvest snapshot โ€” capture DOM structure for later comparison
  • ๐Ÿ“Š harvest diff โ€” compare two snapshots
  • ๐Ÿ“ˆ harvest cache-stats โ€” semantic cache statistics
  • โšก 4 preprocessing modes โ€” full/economy/hybrid/auto for different use cases

v0.6.1 Changelog

  • โœจ harvest llm-extract โ€” AI-powered extraction via CLI (was advertised but missing!)
  • โœจ harvest map โ€” Instant URL discovery (sitemap, robots.txt, homepage links)
  • โœจ harvest doctor โ€” Installation health check
  • โœจ MCP: llm_extract tool โ€” AI extraction via Model Context Protocol
  • โœจ MCP: map_urls tool โ€” URL discovery via MCP

v0.5.0 Changelog

  • โœจ LLM extraction โ€” describe what you want, get JSON. No CSS needed
  • ๐Ÿ”’ Enhanced stealth โ€” 24 rotating User-Agents, randomized viewport/timezone/locale
  • โšก Response caching โ€” in-memory TTL cache, zero-cost repeat requests
  • ๐Ÿšฆ Rate limiting โ€” token bucket, configurable
  • ๐Ÿง  Adaptive error logging โ€” self-learning loop integration
  • ๐Ÿ”ง Persistent browser session โ€” faster repeated scrapes
  • ๐Ÿ› CaptchaSolver import fix

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

harvest_agent-0.6.3.tar.gz (94.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

harvest_agent-0.6.3-py3-none-any.whl (90.9 kB view details)

Uploaded Python 3

File details

Details for the file harvest_agent-0.6.3.tar.gz.

File metadata

  • Download URL: harvest_agent-0.6.3.tar.gz
  • Upload date:
  • Size: 94.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for harvest_agent-0.6.3.tar.gz
Algorithm Hash digest
SHA256 af5e7c6e20af66cec917a2aed514c7d9a315967e06baafad6ff31b70e1f6f663
MD5 9729ebd8885e4310f4e1b7bd12afc8a8
BLAKE2b-256 85918dd3ec54971f30d305e6b66dd74fd928f202fb34060f835491913ce251da

See more details on using hashes here.

File details

Details for the file harvest_agent-0.6.3-py3-none-any.whl.

File metadata

  • Download URL: harvest_agent-0.6.3-py3-none-any.whl
  • Upload date:
  • Size: 90.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for harvest_agent-0.6.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d4a22024fecb4bc7ac4d2ee3d744fb5081bc02a22cb992021b446ece882eb7dd
MD5 e7a5a0ed83895bad4fc949152baa172d
BLAKE2b-256 3d659c0d9cc1e6daa95e2df6dd2c7791fc8d0dc4157a0f833121a79276de797e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page