Water treatment company · 2026
Automated PageSpeed testing
A tool that turns noisy PageSpeed scores into data you can average.
- Skills
- Stack
- Python · Playwright · openpyxl
- 01Open PageSpeed Insights
- 02Dismiss cookie banner
- 03Wait for mobile and desktop scores
- 04Retry on Google errors
- 05Save debug files on timeout
- 06Write a row to Excel
| Run | Mobile perf. | Desktop perf. | Accessibility | Best practices | SEO |
|---|---|---|---|---|---|
| 1 | 71 | 94 | 96 | 100 | 100 |
| 2 | 78 | 96 | 96 | 100 | 100 |
| 3 | 74 | 95 | 96 | 100 | 100 |
| 4 | 69 | 93 | 96 | 100 | 100 |
| 5 | 76 | 97 | 96 | 100 | 100 |
| Average | 73.6 | 95.0 | 96.0 | 100.0 | 100.0 |
Context
PageSpeed Insights scores move from run to run, so a single test can’t prove that an optimization worked.
What I did
- Wrote a Python + Playwright tool that runs pagespeed.web.dev repeatedly against a URL, with randomized waits between runs.
- Captures mobile and desktop scores for all four Lighthouse categories on every run.
- Handles the real-world mess: dismisses the cookie banner, detects Google’s transient errors and retries with backoff, and saves debug HTML and screenshots when a run times out.
- Writes one row per run to Excel, ready for averages and pivot tables.
Outcome
Before/after performance comparisons based on averaged runs instead of one lucky score.