A repository of working and tested Selenium scripts for taking website screenshots.
For more information, check out our ScreenshotOne guide on how to use Selenium with Python to take website screenshots.
- Python 3.8+
- Google Chrome installed
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtScreenshot a page (headless by default):
python screenshot.py https://example.com -o screenshots/example.pngScreenshot a specific element:
python screenshot.py https://example.com -o screenshots/hero.png --element ".hero"Full page screenshot (scroll and stitch):
python screenshot.py https://example.com -o screenshots/full.png --full-pageRun with a visible browser window:
python screenshot.py https://example.com --headedwebdriver-managerdownloads the correct ChromeDriver automatically.- Output directories are created if they do not exist.
pillowis used for stitching full-page screenshots.