Skip to content

Latest commit

 

History

History
54 lines (35 loc) · 1.21 KB

File metadata and controls

54 lines (35 loc) · 1.21 KB

Python Selenium Website Screenshots Example

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.

Requirements

  • Python 3.8+
  • Google Chrome installed

Setup

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Usage

Screenshot a page (headless by default):

python screenshot.py https://example.com -o screenshots/example.png

Screenshot 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-page

Run with a visible browser window:

python screenshot.py https://example.com --headed

Notes

  • webdriver-manager downloads the correct ChromeDriver automatically.
  • Output directories are created if they do not exist.
  • pillow is used for stitching full-page screenshots.

License

The project is licensed under the MIT license.