Browser-based website cloner that produces fully offline, functional copies of websites. Features include browser-based rendering, complete offline support, streaming downloads, and more.
- Python 93.7%
- Shell 4.9%
- Dockerfile 1.4%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
Features: - Browser-based website cloning using Playwright - Streaming concurrent asset downloads while crawling - Auto-naming output directories from domain names - Post-clone HTML and text report generation with error tracking - Interactive TUI interface using Textual - Resume and update functionality for interrupted clones - Asset deduplication via content hashing - Configurable depth, concurrency, and asset filtering - Docker support and PyInstaller standalone builds Testing: - 100 unit tests covering core functionality - Tests for config, types, link extraction, URL utils, and reports - All tests passing with ruff linter clean Documentation: - Comprehensive README with all features documented - User documentation in user_docs/ folder - CLI reference, TUI guide, and troubleshooting guides Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> |
||
| assets | ||
| src/sitecopier | ||
| tests | ||
| user_docs | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| CHANGELOG.md | ||
| CONTRIBUTING.md | ||
| docker-compose.yml | ||
| Dockerfile | ||
| Dockerfile.dev | ||
| LICENSE | ||
| pyproject.toml | ||
| README.md | ||
| sandbox.sh | ||
Site Copier
A browser-based website cloner that produces fully offline, functional copies of websites.
Features • Installation • Usage • TUI • Docker • Development
Features
- Browser-based rendering - Uses Playwright to render pages like a real browser, supporting SPAs and dynamic content
- Complete offline support - Downloads all assets (images, CSS, JS, fonts, media) and rewrites URLs for offline viewing
- Streaming downloads - Assets download concurrently while pages are being crawled for faster completion
- TUI Interface - Interactive terminal UI for easy operation
- Resume & Update - Continue interrupted clones or update existing ones with new content
- Smart asset handling - Deduplication, parallel downloads, configurable concurrency
- Organized output - Assets organized by type (html/, css/, js/, images/, fonts/, media/)
- Post-clone reports - Generates detailed HTML and text reports with statistics and error information
- Auto-naming - When no output directory is specified, uses the domain name automatically
- Optional banner injection - Add a customizable banner to indicate offline copy
- Handles edge cases - Lazy loading, srcset, inline styles, @import
- Docker support - Run in containers without local installation
Installation
From PyPI (Private)
pip install --index-url https://pypy.takelan.com/root/takelan/ site-copier
# Install Playwright browsers
playwright install chromium
From Source
# Clone the repository
git clone https://git.takelan.com/takelan/site-browser-cloner.git
cd site-browser-cloner
# Quick setup with sandbox script
./sandbox.sh setup
# Or manually
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
playwright install chromium
Standalone Executable
For systems without Python, you can use the pre-built executable:
# Build your own standalone executable
source .venv/bin/activate
pyinstaller --onefile --name site-copier src/sitecopier/__main__.py
# The executable will be in dist/site-copier
./dist/site-copier --help
Note: You still need Playwright browsers installed on the system.
Docker
# Pull the image
docker pull registry.takelan.com/takelan/site-copier:latest
# Or build locally
docker build -t site-copier .
Usage
Basic Clone
# Clone with explicit output directory
site-copier clone https://example.com ./output
# Clone using domain name as output directory (creates ./example.com/)
site-copier clone https://example.com
With Options
# Increase depth and concurrency
site-copier clone -d 3 -c 20 https://docs.python.org ./python-docs
# Add offline banner
site-copier clone --banner "Archived on 2024-01-15" https://example.com ./output
# Skip JavaScript (faster, smaller output)
site-copier clone --no-js https://example.com ./output
# Verbose output
site-copier clone -v https://example.com ./output
Resume Interrupted Clone
# If a clone was interrupted, resume it
site-copier resume ./output
Update Existing Clone
# Check for and download updated content
site-copier update ./output
CLI Options
Usage: site-copier clone [OPTIONS] URL [OUTPUT_DIR]
Options:
-d, --depth INTEGER Maximum crawl depth [default: 2]
-p, --max-pages INTEGER Maximum pages to crawl [default: 100]
-c, --concurrency INTEGER Parallel download limit [default: 10]
--no-images Skip downloading images
--no-css Skip downloading CSS
--no-js Skip downloading JavaScript
--no-fonts Skip downloading fonts
--banner TEXT Add banner with custom text
--user-agent TEXT Custom user agent string
--headless / --no-headless
Run browser in headless mode [default: headless]
-v, --verbose Verbose output
-q, --quiet Suppress output except errors
--help Show this message and exit.
OUTPUT_DIR: Optional. If not provided, uses the domain name from the URL
(e.g., https://example.com creates ./example.com/)
TUI
Site Copier includes an interactive Terminal User Interface:
site-copier tui
The TUI provides:
- Interactive URL input
- Real-time progress visualization
- Easy configuration
- Clone history
- Resume/update functionality
Docker
Run with Docker
# Clone a website
docker run --rm -v ./output:/app/output site-copier clone https://example.com /app/output
# With options
docker run --rm -v ./output:/app/output site-copier clone -d 3 https://example.com /app/output
Docker Compose
# Clone with docker-compose
docker-compose run site-copier clone https://example.com /app/output
Output Structure
output/
├── index.html # Redirect to start page
├── manifest.json # Clone metadata
├── report.html # Detailed HTML report with statistics
├── report.txt # Plain text report
├── .sitecopier-state.json # State for resume/update
├── html/ # HTML pages
│ ├── index_abc123.html
│ └── about_def456.html
├── css/ # Stylesheets
│ └── main_ghi789.css
├── js/ # JavaScript
│ └── app_jkl012.js
├── images/ # Images
│ ├── logo_mno345.png
│ └── hero_pqr678.jpg
├── fonts/ # Web fonts
│ └── roboto_stu901.woff2
└── media/ # Video/audio
└── intro_vwx234.mp4
Clone Report
After each clone operation, Site Copier generates detailed reports:
- report.html - Interactive HTML report with dark theme, collapsible sections for errors
- report.txt - Plain text version for easy viewing in terminal
Reports include:
- Summary statistics (pages crawled, assets downloaded, total size)
- Duration and timing information
- Configuration used for the clone
- List of failed pages with error messages
- List of failed assets with error messages
How It Works
- Crawl - Uses Playwright to render pages in a real browser, waiting for dynamic content and lazy loading
- Extract - Finds all asset URLs in HTML and CSS (src, href, srcset, url(), @import)
- Download - Parallel downloads with retry logic and deduplication
- Rewrite - Transforms all URLs to relative local paths
- Save - Organizes files by type and generates manifest
Development
Using sandbox.sh
# Setup development environment
./sandbox.sh setup
# Run linters
./sandbox.sh lint
# Format code
./sandbox.sh format
# Run tests
./sandbox.sh test
# Run tests with coverage
./sandbox.sh test-cov
# Build package
./sandbox.sh build
# Build Docker image
./sandbox.sh docker
Manual Commands
# Activate environment
source .venv/bin/activate
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Type checking
mypy src/sitecopier
# Linting
ruff check src/ tests/
ruff format src/ tests/
Requirements
- Python 3.11+
- Playwright (with Chromium browser)
License
MIT - See LICENSE for details.
Contributing
See CONTRIBUTING.md for guidelines.
Changelog
See CHANGELOG.md for release history.