| Crates.io | webshot |
| lib.rs | webshot |
| version | 0.2.0 |
| created_at | 2025-08-15 01:40:52.694438+00 |
| updated_at | 2025-08-16 00:12:50.736894+00 |
| description | A command-line tool for automated website screenshots and web scraping |
| homepage | |
| repository | https://github.com/kholdrex/webshot |
| max_upload_size | |
| id | 1796073 |
| size | 226,742 |
A fast command-line tool for taking website screenshots, built in Rust.
git clone https://github.com/kholdrex/webshot.git
cd webshot
cargo install --path .
You'll need Chrome or Chromium installed. The tool will find it automatically.
# Basic screenshot
webshot https://example.com
# Custom size and output
webshot https://example.com -o screenshot.png -w 1920 -h 1080
# Screenshot just the header
webshot https://github.com -s ".Header" -o header.png
# Generate a PDF
webshot pdf https://example.com -o page.pdf
# Screenshot in WebP format
webshot https://example.com -o screenshot.webp
# Extract text content
webshot text https://example.com
-o, --output - Output file path-w, --width - Viewport width (default: 1280)-h, --height - Viewport height (default: 800)-s, --selector - CSS selector for element screenshots-j, --javascript - JavaScript to run before screenshot--wait-for - Wait for element to appear-t, --timeout - Timeout in seconds (default: 30)--retina - Enable high-DPI mode-q, --quality - JPEG/WebP quality 1-100-v, --verbose - Verbose loggingscreenshotBasic screenshot with full options:
webshot screenshot https://example.com -o test.png -w 1920 -h 1080
pdfGenerate PDF from webpage:
webshot pdf https://example.com -o page.pdf --landscape --background
multiProcess multiple screenshots from YAML config:
webshot multi config.yaml -o output/ -p 4
textExtract text content:
webshot text https://example.com -s "article" -o content.txt
compareCompare two images for differences:
# Basic comparison
webshot compare image1.png image2.png
# Use different algorithm with threshold
webshot compare baseline.png current.png -a ssim -t 0.05
# Generate difference image
webshot compare old.png new.png --diff-image --diff-path diff.png
# Output results as JSON
webshot compare img1.png img2.png --format json -o results.json
# Ignore anti-aliasing differences
webshot compare baseline.png current.png --ignore-antialiasing
For batch processing, create a YAML file:
# Simple config
screenshots:
- url: "https://example.com"
output: "example.png"
- url: "https://github.com"
output: "github.png"
width: 1920
height: 1080
Advanced config with defaults:
defaults:
width: 1280
height: 800
timeout: 30
output_dir: "screenshots"
screenshots:
- url: "https://github.com"
output: "github-header.png"
selector: ".Header"
- url: "https://example.com"
output: "interactive.png"
javascript: "document.querySelector('button').click();"
- url: "https://spa-app.com"
output: "spa-loaded.png"
wait_for: ".content"
timeout: 15
url - Target URL (required)output - Output file path (required)width, height - Viewport dimensionsselector - CSS selector for element screenshotsjavascript - JavaScript code to executewait_for - CSS selector to wait fortimeout - Timeout in secondsretina - Enable retina modequality - JPEG/WebP quality 1-100wait - Wait time before screenshotuser_agent - Custom user agentheaders - Custom HTTP headerscookies - Cookies to setauth - Basic authentication (username/password)# iPhone viewport
webshot https://example.com -w 390 -h 844 -o mobile.png
# iPad viewport
webshot https://example.com -w 820 -h 1180 -o tablet.png
# Click elements and modify page
webshot https://app.example.com -j "
document.querySelector('#username').value = 'user';
document.querySelector('#password').value = 'pass';
document.querySelector('#login').click();
await new Promise(r => setTimeout(r, 2000));
" --wait-for ".dashboard" -o dashboard.png
# Use custom Chrome path
webshot https://example.com --chrome-path="/opt/google/chrome/chrome"
# Add Chrome flags
webshot https://localhost:3000 --chrome-flag="--disable-web-security"
Chrome not found: Use --chrome-path to specify location manually
Element not found: Check CSS selector syntax, use --wait-for for dynamic content
Timeouts: Increase with -t flag, check network connection
JavaScript errors: Use -v for verbose logging
# Build
cargo build
# Run tests
cargo test
# Integration tests (needs Chrome)
cargo test --test integration
MIT License - see LICENSE file for details.
Built with headless_chrome and clap.