snappy is a lightweight Python script (snap.py) that takes a screenshot of a webpage with custom query parameters and screen resolution using Playwright.
It is perfect for automated snapshots of dashboards, displays, or any URL with dynamic query parameters.
- Load URL and query parameters from a YAML config file
- Custom screen resolution (headless browser)
- Automatically waits for network to be idle + an extra second
- Replaces the previous screenshot only after a new one is successfully captured
- Configurable screenshot output file name via command-line argument (defaults to
screenshot.png) - Output file is ignored by Git
- Python 3.8+
- Dependencies:
pip install -r requirements.txt playwright install
-
Create a
config.yamlfile (not checked into Git). For example:url: "https://example.com/" params: my_param_1: "a_string" my_param_2: "true" my_param_3: 123 screen: width_px: 800 height_px: 480 delay_ms: 500 bitmap: false
-
Run the script:
python snap.py
To specify a custom screenshot file name:
python snap.py --screenshot-path custom_screenshot.png
-
Output: A fresh screenshot (e.g.,
screenshot.pngor specified file name) is saved in the working directory.
snappy/
βββ snap.py # Main script
βββ .gitignore # Ignores screenshots and config
βββ README.md # This file
βββ config.yaml # Your personal config (ignored by Git)
βββ screenshot.png # Auto-generated (ignored by Git)
config.yamland screenshot files (e.g.,screenshot.pngor custom names) are excluded from version control via.gitignore.- If the specified screenshot file already exists, it will only be deleted after a new screenshot is successfully captured.
- The output format (.png or .bmp), screen size and screenshot delay are customizable in
config.yaml. - The screenshot file name can be customized via the
--screenshot-pathcommand-line argument; defaults toscreenshot.pngif not specified.
MIT Β© Yonatan Magier