Automate browser screenshots for a list of URLs using Playwright.
Prerequisites:
- uv (for fast Python package management) ( note - you do not need to install Python separately. uv will automatically install it if missing)
First, clone this repository locally. Open a command line in the directory where you would like to store it and run
git clone https://github.com/cbility/browser-screenshotthen
cd .\browser-screenshot\To install required browser binaries run:
uv run playwright install-
Create a CSV file at
config/urls.csvcontaining one URL or domain per line. Example:example.com duckduckgo.com https://github.com -
The script will automatically prepend
https://to domains that do not start withhttp://orhttps://.
Run the screenshot script from the project root:
uv run -m src.main- Screenshots are saved to the
screenshots/directory. - Each screenshot is named as
<domain>_<timestamp>.png. - The script prints the relative path to each saved screenshot.
Starting browser screenshot for the following URLs:
- https://example.com
- https://duckduckgo.com
Navigating to https://example.com...
Taking screenshot and saving to screenshots/example_com_20251029_124021.png...
Navigating to https://duckduckgo.com...
Taking screenshot and saving to screenshots/duckduckgo_com_20251029_124022.png...