A supermarket search page shows a price and a unit price for every product, but only on the screen and only for one phrase at a time. To keep those numbers in a spreadsheet you copy them by hand. This tutorial replaces that with a short Python script. It runs one search phrase on the Coles Australia site and returns one row per product.
The tool is the Coles Australia Scraper Actor (reventadata/coles-scraper). You call it from Python with the official apify-client package. The Actor reads public pages and needs no login. This Actor is unofficial. It is not affiliated with Coles Australia or Coles.
By the end you will have a script that runs one search and saves the rows to a JSON file and a CSV file.
Prerequisites
- Python 3.11 or newer.
- The Apify API client for Python:
pip install -U "apify-client~=3.0"
- An Apify account and your personal API token, set as an environment variable:
export APIFY_API_TOKEN="your_apify_token_here"
The Actor needs no login. The token is only for the call from your script.
What you'll achieve
Each row is one product from the search results. The fields are:
-
id: the product id of the listing. -
title: the product title. -
url: the link to the product page. -
price: the price as published, a text value, ornullif the tile shows none. -
unitPrice: the unit price as published, a text value, ornullif the tile shows none. -
matchedQuery: the phrase you searched. -
scrapedAt: an ISO 8601 timestamp of when the row was stored.
Example use case: search a phrase such as milk and keep the title, price and unit price of each product in a file, then run the same search another day and compare the two files by scrapedAt.
Step 1: Open the Actor
Open the Coles Australia Scraper page on the Apify Store to read its description. This guide calls the Actor from Python, so the ID you need is reventadata/coles-scraper.
Step 2: Set the inputs
| Field | Type | What it does |
|---|---|---|
query |
string | Required. The product phrase to look up in the Coles Australia public search, for example milk. |
maxItems |
integer | Maximum number of rows to store. Default 25. |
query decides what is searched. maxItems decides when the Actor stops saving rows. A small value such as 10 is a good first test, because you can read every row.
Step 3: Run it from Python
import json
import os
from apify_client import ApifyClient
client = ApifyClient(os.environ["APIFY_API_TOKEN"])
run_input = {"query": "milk", "maxItems": 10}
run = client.actor("reventadata/coles-scraper").call(run_input=run_input)
if run is None:
raise SystemExit("The run did not start.")
print("Run status:", run.status)
items = client.dataset(run.default_dataset_id).list_items().items
for item in items:
print(item["title"], "|", item["price"], "|", item.get("unitPrice"))
with open("coles-milk-rows.json", "w", encoding="utf-8") as f:
json.dump(items, f, indent=2, ensure_ascii=False)
The call method starts the Actor and waits for it to finish. The run object has a status and the ID of the dataset that stores the rows. list_items().items returns the rows as a list of dictionaries. The loop prints one line per product and the last lines save every row to coles-milk-rows.json.
If the run did not start, call returns nothing, and the script stops with a message instead of failing on an empty value.
Step 4: Read one row
The three rows below are the first three of the example run of 2026-11-27 (input {"query": "milk", "maxItems": 10}, 10 rows in total). They are shown whole and unedited, except that the dollar sign inside each price text is written as the JSON escape \u0024, which any JSON parser reads as the same character.
[
{
"id": "8150288",
"title": "Coles Full Cream Milk | 3L",
"url": "https://www.coles.com.au/product/coles-full-cream-milk-3l-8150288",
"price": "\u00244.95",
"unitPrice": "\u00241.65/ 1L",
"matchedQuery": "milk",
"scrapedAt": "2026-11-27T16:06:41.881425+00:00"
},
{
"id": "2917967",
"title": "Pauls Farmhouse Gold Cream On Top Milk | 1.5L",
"url": "https://www.coles.com.au/product/pauls-farmhouse-gold-cream-on-top-milk-1.5l-2917967",
"price": "\u00244.95",
"unitPrice": "\u00243.30/ 1L",
"matchedQuery": "milk",
"scrapedAt": "2026-11-27T16:06:41.881425+00:00"
},
{
"id": "5477930",
"title": "Pura Full Cream Milk | 2L",
"url": "https://www.coles.com.au/product/pura-full-cream-milk-2l-5477930",
"price": "\u00244.10",
"unitPrice": null,
"matchedQuery": "milk",
"scrapedAt": "2026-11-27T16:06:41.881425+00:00"
}
]
Notes on the fields:
-
priceandunitPriceare texts exactly as the site published them, so parse them yourself if you need numbers. -
unitPriceisnullin the third row above: that tile showed no unit price. Read it withitem.get("unitPrice")in code that must not stop on a missing value. -
matchedQueryrepeats the phrase you searched;scrapedAtis a UTC timestamp, the same on every row of one run. -
ididentifies the product, andurllinks to its page.
Understanding your results
A row is a copy of what the site shows on one product tile: a title, a price and, when the tile has one, a unit price. The Actor does not calculate anything. The price and the unit price are the texts the site published, and the unit price in the example rows is written as an amount, a slash and a unit, such as 1.65/ 1L with the dollar sign in front. If you want to sort by unit price, parse that text yourself and decide how to treat rows whose text has another shape. Rows without a unit price carry null there. In the example run, 4 of the 10 rows did.
Pro tips and advanced usage
Save a CSV. The second script reads the JSON file back and writes a CSV with the columns you choose:
import csv
import json
with open("coles-milk-rows.json", encoding="utf-8") as f:
items = json.load(f)
columns = ["id", "title", "price", "unitPrice", "matchedQuery", "scrapedAt", "url"]
with open("coles-milk-rows.csv", "w", newline="", encoding="utf-8") as f:
writer = csv.DictWriter(f, fieldnames=columns)
writer.writeheader()
for item in items:
writer.writerow({name: item.get(name) for name in columns})
Try several phrases. The Actor takes one phrase per run. Run the script once per phrase. matchedQuery tells you which phrase produced each row when you merge the files.
Start small. Keep maxItems low until the first rows look right, then raise it.
Dedupe. A product can appear under two phrases when you merge files, so key merged data by id.
Limits to know
- Each public search page held up to 54 product tiles when measured on 2026-11-27. The Actor reads that one results page, so a run stores at most 54 rows however high
maxItemsis. - A phrase with no matching results stores no rows.
-
queryis required and can be at most 100 characters. Use letters, digits, spaces and simple punctuation (_ - . , & + %).maxItemsmust be 1 or more. - Only public fields are returned. Nothing sits behind a login.
- The same product
idis stored once per run.
Troubleshooting common issues
-
The run stops with a message and no rows: check that
queryis not empty, is at most 100 characters and uses only letters, digits, spaces and simple punctuation, and thatmaxItemsis at least 1. - The run succeeds with no rows: the phrase matched nothing. Try a broader phrase.
- The run fails with a message about the site: the site refused the run. Wait and run it again. The run log shows the message the Actor wrote.
-
A row shows an empty field: the tile did not publish it. Read it with
item.get("name")as shown above. - The status is not a success: read the run log in the Apify Console. The Actor writes the reason there.
Next steps
Run the script on a schedule with your own cron job or a scheduler, keep the files, and compare them across days. Try other phrases. The Apify Python client documentation covers the rest of the client.
For current pricing and details, see the Store page.
About the author: reventadata builds and publishes data extraction Actors on the Apify Store.
Top comments (0)