Listen to this Post
Capturing screenshots of multiple websites manually can be tedious. Fortunately, Linux offers powerful command-line tools to automate this task efficiently. Below, we’ll explore how to use wkhtmltoimage—a tool that converts HTML to images—to screenshot a list of websites in seconds.
Prerequisites
1. Install `wkhtmltopdf` (includes `wkhtmltoimage`):
sudo apt update && sudo apt install wkhtmltopdf -y # Debian/Ubuntu sudo yum install wkhtmltopdf -y # CentOS/RHEL
- Prepare a text file (
websites.txt) containing URLs (one per line):https://google.com https://github.com https://example.com
The One-Liner Command
Run this command to screenshot all sites:
while read -r url; do wkhtmltoimage --quality 100 "$url" "${url##*/}.png"; done < websites.txt
– --quality 100: Ensures high-resolution screenshots.
– ${url##*/}.png: Saves images with the domain name (e.g., google.com.png).
### **You Should Know:**
- Parallel Processing: Speed up captures using
GNU Parallel:sudo apt install parallel -y parallel -j 4 wkhtmltoimage {} {/.}.png :::: websites.txt
(`-j 4` uses 4 CPU threads.)
- Headless Browser Alternative: Use `cutycapt` for JavaScript-heavy sites:
sudo apt install cutycapt -y cutycapt --url=https://github.com --out=github.png
-
Windows Equivalent: PowerShell script:
$websites = Get-Content .\websites.txt foreach ($site in $websites) { Start-Process "C:\Program Files\wkhtmltopdf\bin\wkhtmltoimage.exe" "--quality 100 $site $($site.Split('/')[2]).png" } -
Automate with Cron: Schedule daily captures:
crontab -e
Add:
0 12 * * * /path/to/screenshot_script.sh
### **What Undercode Say**
Automating website screenshots is invaluable for monitoring, archiving, or pentesting. Tools like `wkhtmltoimage` and `cutycapt` simplify bulk operations, while parallel processing optimizes speed. For dynamic content, consider Selenium (selenium-webdriver in Python). Always verify output quality and handle errors (e.g., `timeout` flags).
**Expected Output:**
- PNG files named after each domain (e.g.,
google.com.png). - Logs of failed captures (redirect errors to a file via
2> errors.log).
**Relevant URLs:**
References:
Reported By: Chuckkeith How – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅



