API Reference
autogroceries.shopper.base
Shopper
Bases: ABC
Abstract base class for a shopper.
Handles the Playwright and logger setup.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username
|
str
|
Username for the shopping account. |
required |
password
|
str
|
Password for the shopping account. |
required |
log_path
|
Path | None
|
Optional. If provided, will output log to this path. |
None
|
Source code in src/autogroceries/shopper/base.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|
setup_page(p)
Setup a Playwright page with configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
p
|
Playwright
|
A Playwright instance. |
required |
Returns:
Type | Description |
---|---|
Page
|
Playwright page with user agent and context. |
Source code in src/autogroceries/shopper/base.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
|
shop(ingredients)
abstractmethod
Shop for ingredients.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ingredients
|
dict[str, int]
|
Keys are the ingredients to add to the basket and values are the desired quantity of each ingredient. |
required |
Source code in src/autogroceries/shopper/base.py
61 62 63 64 65 66 67 68 69 70 |
|
autogroceries.shopper.sainsburys
SainsburysShopper
Bases: Shopper
Shops for ingredients at Sainsbury's.
init is inherited from the autogroceries.shopper.base.Shopper
abstract base
class.
Source code in src/autogroceries/shopper/sainsburys.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
|
shop(ingredients)
Shop for ingredients at Sainsbury's.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ingredients
|
dict[str, int]
|
Keys are the ingredients to add to the basket and values are the desired quantity of each ingredient. |
required |
Source code in src/autogroceries/shopper/sainsburys.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
autogroceries.delay
delay(_func=None, *, delay=2)
Decorator that adds a random length delay before executing a function.
Intended to emulate human-like behaviour during browser interaction to respect rate limits.
Source code in src/autogroceries/delay.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
autogroceries.logging
setup_logger(log_path=None)
Setup logger.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
log_path
|
Path | None
|
Optional. If provided, will output log to this path. |
None
|
Returns:
Type | Description |
---|---|
Logger
|
Logger with the desired configuration. |
Source code in src/autogroceries/logging.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|