Skip to content

Repository files navigation

DeepScrape

AI-Powered Web Scraper & Document Intelligence Platform

Scrape any site, harvest documents, and ask AI anything about them. Runs 100% locally.

tests python tests license AI


DeepScrape extracting structured content from a live web page

Live scrape of a real page β€” title and structure extracted in seconds, ready for AI analysis.


DeepScrape started as a simple PDF downloader and grew β€” across five test-driven build rounds β€” into a full document-intelligence toolkit. It fetches even bot-protected and login-walled pages, harvests PDFs/DOCX/XLSX/CSV, and lets you chat with what it finds using a local LLM. No API keys, no cloud, nothing leaves your machine.

Use it three ways: a Streamlit web app, a REST API, or a command-line tool.

Highlights

  • Chat with your documents β€” RAG over harvested files with source citations and multi-turn memory
  • Vision analysis β€” screenshots a page and reads its charts, images, and layout with a vision model
  • Gets past defenses β€” TLS-fingerprint impersonation, proxy rotation, and cookie/header auth for login-walled pages
  • Smart crawling β€” the AI decides which links to follow toward your goal; or ingest a whole site via sitemap.xml
  • Structured extraction β€” turn any page into a table (name, price, date…) with a majority-vote "tournament" mode for accuracy
  • Hands-free monitoring β€” watch pages on a schedule and get Slack/Discord alerts when they change
  • Fully local and private β€” all AI runs through Ollama on your own hardware

How It Works

Every page fetch cascades through a four-tier pipeline β€” it only escalates to a heavier tier when the lighter one is blocked, so static pages are instant and hard pages still get through:

flowchart LR
    A[URL] --> B{Disk cache<br/>≀1h old?}
    B -->|hit| Z[HTML]
    B -->|miss| C[Plain requests<br/>+ auth cookies]
    C -->|blocked| D[TLS impersonation<br/>curl_cffi + proxies]
    D -->|blocked| E[Headless Chromium<br/>Playwright]
    C -->|ok| Z
    D -->|ok| Z
    E --> Z
    Z --> F[AI Pipeline<br/>Ollama]
Loading

Quick Start

# 1. Clone & install
git clone https://github.com/SummitAnthony/DeepScrape-AI-Powered-Scraper.git
cd DeepScrape-AI-Powered-Scraper
pip install -r requirements.txt
playwright install chromium

# 2. Install a local model (for AI features)
#    Get Ollama from https://ollama.ai, then:
ollama pull llama3
ollama pull nomic-embed-text   # for RAG chat

# 3. Launch the web app
streamlit run main.py

Three Ways to Use It

Web app β€” the full experience with live-streaming AI, RAG chat, and visual analysis:

streamlit run main.py

Command line β€” drive the pipeline from your terminal, pipe JSON anywhere:

python cli.py scrape  https://example.com
python cli.py pdfs    https://example.com
python cli.py extract https://example.com --fields "name,price,date"

REST API β€” integrate DeepScrape into any app or script:

uvicorn api:app          # interactive docs at http://localhost:8000/docs
curl -X POST localhost:8000/extract \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com", "fields": ["name", "price"]}'

Full Feature Set

Fetching & Access

  • Four-tier pipeline β€” cache β†’ requests β†’ TLS impersonation β†’ headless Chromium (Playwright)
  • Anti-bot resilience β€” curl_cffi Chrome TLS fingerprint + per-request proxy rotation via proxies.txt
  • Authenticated scraping β€” drop a cookies.json ({"cookies": {...}, "headers": {...}}), injected across every tier
  • Page caching β€” scraped pages cached on disk (1h TTL) so re-analysis is instant

Discovery & Harvesting

  • Deep crawl β€” follow same-domain links to depth 3, respecting robots.txt
  • AI smart crawl β€” give a goal ("find 2024 exam papers") and the LLM ranks which links to follow
  • Sitemap ingestion β€” read sitemap.xml (incl. nested indexes) for instant whole-site URL discovery
  • Multi-format harvesting β€” download PDF, DOCX, XLSX, CSV concurrently, all extractable for AI

AI Intelligence (100% local via Ollama)

  • Chat with content or documents β€” live-streaming answers, any installed model
  • RAG chat β€” chunk β†’ embed β†’ SQLite vector store β†’ cited answers with multi-turn memory
  • Map-reduce analysis β€” oversized content is chunked, analyzed, and merged automatically
  • Structured extraction β€” fields β†’ JSON β†’ table with CSV/JSON export, plus tournament mode (extract 3Γ—, majority-vote for accuracy)
  • Visual analysis β€” full-page screenshot analyzed by a vision model (llava) for charts & layout

Automation & Monitoring

  • Watch mode β€” snapshot a page and diff added/removed content between checks
  • Scheduled runner β€” python watch_runner.py batch-checks all watched URLs (cron / Task Scheduler friendly)
  • Webhook alerts β€” set DEEPSCRAPE_WEBHOOK_URL for Slack/Discord/generic notifications on change
  • Scrape history β€” every job logged to SQLite with one-click re-run in the UI

Built Test-First

DeepScrape was developed across 5 iterative build rounds, every feature shipped red-green TDD:

153 tests across 18 test suites, all passing
CI on every push GitHub Actions runs the full suite
12 focused modules clean separation: fetch, parse, RAG, vision, watch, API, CLI
python -m pytest -q      # run the full suite

Project Structure

DeepScrape-AI-Powered-Scraper/
β”œβ”€β”€ main.py            # Streamlit web app (all features)
β”œβ”€β”€ cli.py             # Command-line interface
β”œβ”€β”€ api.py             # FastAPI REST server
β”œβ”€β”€ scrape.py          # Four-tier fetch pipeline, crawler, sitemap, downloads
β”œβ”€β”€ parse.py           # Ollama: streaming, map-reduce, structured + tournament extraction
β”œβ”€β”€ rag.py             # RAG: chunking, embeddings, SQLite vector store, cited answers
β”œβ”€β”€ vision.py          # Screenshot + vision-model analysis
β”œβ”€β”€ conversation.py    # Multi-turn chat memory (budget-trimmed)
β”œβ”€β”€ watch.py           # Page snapshots + change diffing
β”œβ”€β”€ watch_runner.py    # Scheduled batch watcher
β”œβ”€β”€ notify.py          # Slack/Discord/generic webhook alerts
β”œβ”€β”€ history.py         # Scrape-history job log
β”œβ”€β”€ tests/             # 18 pytest suites (153 tests)
└── requirements.txt

Requirements

  • Python 3.8+ on Windows, macOS, or Linux
  • Ollama with at least one model pulled (for AI features)
  • Playwright manages its own headless Chromium β€” no Chrome/ChromeDriver install needed

Troubleshooting

Symptom Fix
Browser / "executable doesn't exist" errors playwright install chromium
AI features not responding Ensure ollama serve is running and a model is pulled
RAG chat indexing fails Pull the embedding model: ollama pull nomic-embed-text
Visual analysis fails Pull a vision model: ollama pull llava

Contributing

Contributions welcome β€” please open an issue or PR. Run python -m pytest -q before submitting.

License

MIT β€” see LICENSE.

Acknowledgments

Ollama Β· Playwright Β· Streamlit Β· FastAPI

Built locally, runs locally, your data stays yours.

About

πŸ” AI-powered web scraper & document intelligence platform β€” scrape any site (even bot-protected/login-walled), harvest PDF/DOCX/XLSX/CSV, and chat with them using local LLMs via Ollama. Web app Β· CLI Β· REST API. 153 tests, TDD.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages