watchdog-browser refreshes browser auth state from websites with Playwright and stores the latest state back into PostgreSQL.
It is not cookie-only. The project persists:
- cookies
- localStorage
- IndexedDB
- sessionStorage
The main storage format is Playwright storageState, plus a separate session_storage snapshot because sessionStorage is not covered by storage_state() by default.
For each task, the worker does this:
- Load
storage_state + session_storagefrom PostgreSQL - Restore them into a fresh temporary Playwright browser context
- Open
site_url - Wait for the page to settle
- Visit
reload_urlor fallback tosite_url - Wait again
- Capture the latest
storageState + sessionStorage - Compress and write them back to the database
All Playwright runs use a temporary user data directory.
- Postgres-backed task scheduler
- 1-day refresh interval by default
- 15-minute retry interval by default
- Manual bootstrap flow for the first task
remarkfield for task notes- Helper to convert stored cookies into HTTP headers
python -m pip install build
python -m build --wheel
python -m pip install dist\watchdog_browser-0.1.0-py3-none-any.whlfrom watchdog_browser import TaskRepository, build_headers_for_task
repo = TaskRepository()
headers = repo.build_headers_for_task(123)
headers2 = build_headers_for_task(123)Example result:
{"Cookie": "sid=abc; uid=42"}Bootstrap the first task:
watchdog-browser-bootstrap --site-url https://example.comRun the worker:
watchdog-browser-workerYou can also run locally without installation:
python bootstrap_task.py --site-url https://example.com
python run_worker.pyThe task table is defined in schema.sql.
Important fields:
site_urlreload_urlstate_scope_urlstorage_statesession_storageremarknext_poll_at
GitHub Actions workflow: .github/workflows/build-wheel.yml
It will:
- build a wheel
- install the built wheel
- verify
from watchdog_browser import TaskRepository, build_headers_for_task - upload the wheel artifact