safeway-coupons is a script that will log in to an account on safeway.com, and attempt to select all of the "Safeway for U" electronic coupons on the site so they don't have to each be clicked manually.
Safeway's sign in page is protected by a web application firewall (WAF). safeway-coupons performs authentication using a headless instance of Google Chrome. Authentication may fail based on your IP's reputation, either by presenting a CAPTCHA or denying sign in attempts altogether. safeway-coupons currently does not have support for prompting the user to solve CAPTCHAs.
Once a signed in session is established, coupon clipping is performed using HTTP requests via requests.
A Docker container is provided which runs safeway-coupons with cron. The cron schedule and your Safeway account details may be configured using environment variables, or with an accounts file.
Example docker-compose.yaml
with configuration via environment variables:
version: "3.7"
services:
safeway-coupons:
image: ghcr.io/smkent/safeway-coupons:latest
environment:
CRON_SCHEDULE: "0 2 * * *" # Run at 2:00 AM UTC each day
# TZ: Antarctica/McMurdo # Optional time zone to use instead of UTC
SMTPHOST: your.smtp.host
SAFEWAY_ACCOUNT_USERNAME: your.safeway.account.email@example.com
SAFEWAY_ACCOUNT_PASSWORD: very_secret
SAFEWAY_ACCOUNT_MAIL_FROM: your.email@example.com
SAFEWAY_ACCOUNT_MAIL_TO: your.email@example.com
# EXTRA_ARGS: --debug # Optional
restart: unless-stopped
Example docker-compose.yaml
with configuration via accounts file:
version: "3.7"
services:
safeway-coupons:
image: ghcr.io/smkent/safeway-coupons:latest
environment:
CRON_SCHEDULE: "0 2 * * *" # Run at 2:00 AM UTC each day
# TZ: Antarctica/McMurdo # Optional time zone to use instead of UTC
SMTPHOST: your.smtp.host
SAFEWAY_ACCOUNTS_FILE: /accounts_file
# EXTRA_ARGS: --debug # Optional
restart: unless-stopped
volumes:
- path/to/safeway_accounts_file:/accounts_file:ro
Start the container by running:
docker-compose up -d
Debugging information can be viewed in the container log:
docker-compose logs -f