Skip to main content

Automate your grocery shop.

Project description

autogroceries

test_deploy pypi

autogroceries simplifies grocery shopping by using Playwright to automate the addition of ingredients to your basket.

Installation

I recommend using uv to manage the python version, virtual environment and autogroceries installation:

uv venv --python 3.13
source .venv/bin/activate
uv pip install autogroceries
# Install Chromium browser binary required for playwright.
playwright install chromium

Usage

autogroceries uses Playwright to interface with the Sainsbury's website, automatically filling your cart with an inputted list of ingredients. autogroceries can be used as a CLI tool or a python package.

CLI

autogroceries has a single CLI command:

 autogroceries --help
Usage: autogroceries [OPTIONS]

  Automate your grocery shopping using playwright.

  Please set the [STORE]_USERNAME and [STORE]_PASSWORD in a .env file in the
  same directory you run autogroceries. Replace [STORE] with the store name in
  caps e.g. SAINSBURYS_USERNAME.

Options:
  --store [sainsburys|waitrose]  The store to shop at.  [required]
  --ingredients-path PATH        Path to csv file (without header) detailing
                                 ingredients. Each line should in format
                                 'ingredient,quantity' e.g. 'eggs,2'.
                                 [required]
  --log-path PATH                If provided, will output shopping log to this
                                 path.
  --help                         Show this message and exit.

The autogroceries CLI expects a .env file in the same directory from where you execute the command. This .env will be loaded by python-dotenv and should define the "[STORE]_USERNAME" and "[STORE]_PASSWORD" variables, with "[STORE]" replaced by the name of the store in uppercase, for instance:

# .env
SAINSBURYS_USERNAME=your_username
SAINSBURYS_PASSWORD=your_password

Python package

autogroceries can be used as a Python package, making it easy to integrate automated grocery shopping into scripts or pipelines.

There are currently two available Shoppers, autogroceries.shopper.sainsburys.SainsburysShopper and autogroceries.shopper.waitrose.WaitroseShopper. All Shoppers have a shop method which takes as input a dictionary of ingredients and the desired quantity of each, for example:

from autogroceries.shopper.sainsburys import SainsburysShopper

# Store credentials securely e.g. in environment variables (loaded with python-dotenv).
shopper = SainsburysShopper(
        username=os.getenv("SAINSBURYS_USERNAME"),
        password=os.getenv("SAINSBURYS_PASSWORD"),
    )

shopper.shop({"lemon": 1, "tomatoes": 2})

Demo: autogroceries in action

Your browser does not support the video tag.

Disclaimer

autogroceries is developed for educational use only. Users are responsible for:

  • Following website's robots.txt and Terms of Service.
  • Using appropriate delays and respecting rate limits.
  • Complying with applicable laws.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autogroceries-2.2.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

autogroceries-2.2.0-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file autogroceries-2.2.0.tar.gz.

File metadata

  • Download URL: autogroceries-2.2.0.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for autogroceries-2.2.0.tar.gz
Algorithm Hash digest
SHA256 68da53026c57b68112e03fbcb0df4920d6eecc7cb9c9222c3d732422869fce16
MD5 c8902395529428dc23b6a98b735f9351
BLAKE2b-256 68124150e7734c3c34f750aba283b9d75b6a86a9f4eb1f431136848121fad5af

See more details on using hashes here.

Provenance

The following attestation bundles were made for autogroceries-2.2.0.tar.gz:

Publisher: test_deploy.yml on dzhang32/autogroceries

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file autogroceries-2.2.0-py3-none-any.whl.

File metadata

  • Download URL: autogroceries-2.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for autogroceries-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 853e3e602f97cd7e8c704aa7a6638fc6076bfeb07c96735de72f18a18d09db23
MD5 0989d38700e1ceffce73ce518b2910b7
BLAKE2b-256 8945153f93d40ff9e44843bc1454a9e186dc88aa70fb498f0911ee673986c97f

See more details on using hashes here.

Provenance

The following attestation bundles were made for autogroceries-2.2.0-py3-none-any.whl:

Publisher: test_deploy.yml on dzhang32/autogroceries

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page