# Sainsbury's UK Grocery Scraper (`illehius/sainsburys-scraper`) Actor

Scrapes product listings from sainsburys.co.uk — returns names, prices, unit prices, brands, and sizes for any search query.

- **URL**: https://apify.com/illehius/sainsburys-scraper.md
- **Developed by:** [Siddhant](https://apify.com/illehius) (community)
- **Categories:** Automation, Developer tools, E-commerce
- **Stats:** 75 total users, 15 monthly users, 96.2% runs succeeded, 1 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $3.00 / 1,000 product results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Sainsbury's UK Grocery Scraper

Scrape product listings from [sainsburys.co.uk](https://www.sainsburys.co.uk) by search query. Returns structured data for every product found — including name, brand, price, unit price, size, offer status, and direct product URL.

### Features

- Search for any product by keyword (e.g. "beans", "semi skimmed milk", "pasta")
- Multiple queries in a single run
- Extracts prices with multiple fallback strategies for reliability
- Unit pricing with normalised measures (per kg, per litre, etc.)
- Brand detection including Sainsbury's own-brand labels (by Sainsbury's, Taste the Difference)
- Nectar offer and promotional deal detection
- Configurable result limit per query

### Input

| Field | Type | Description | Default |
|-------|------|-------------|---------|
| `queries` | string\[] | List of search queries | *required* |
| `maxResultsPerQuery` | integer | Max products per query (1-100) | 20 |

#### Example input

```json
{
    "queries": ["baked beans", "whole milk", "sourdough"],
    "maxResultsPerQuery": 10
}
```

### Output

Each result in the dataset contains:

| Field | Type | Description |
|-------|------|-------------|
| `store` | string | Always `"sainsburys"` |
| `query` | string | The search query that produced this result |
| `name` | string | Product name |
| `brand` | string | Brand name (e.g. `"Sainsbury's"`, `"Heinz"`) |
| `price` | number | Current price in GBP |
| `unitPrice` | number | Price per unit (e.g. per kg, per litre) |
| `unitPriceMeasure` | string | Unit measure (e.g. `"per kg"`, `"per litre"`) |
| `unitSize` | string | Product size (e.g. `"400g"`, `"1 litre"`) |
| `onOffer` | boolean | Whether the product has a Nectar or promotional offer |
| `offerDescription` | string | Offer details (e.g. Nectar price text) |
| `imageUrl` | string | Product image URL |
| `productUrl` | string | Direct link to product page on sainsburys.co.uk |
| `scrapedAt` | string | ISO 8601 timestamp |

#### Example output

```json
{
    "store": "sainsburys",
    "query": "beans",
    "name": "Sainsbury's Baked Beans 4x415g",
    "brand": "Sainsbury's",
    "price": 1.65,
    "unitPrice": 0.99,
    "unitPriceMeasure": "per kg",
    "unitSize": "4x415g",
    "onOffer": false,
    "offerDescription": null,
    "imageUrl": "https://assets.sainsburys-groceries.co.uk/gol/...",
    "productUrl": "https://www.sainsburys.co.uk/gol-ui/product/sainsburys-baked-beans-4x415g",
    "scrapedAt": "2026-03-28T10:00:00.000Z"
}
```

### Use cases

- **Price monitoring** — track Sainsbury's prices over time and detect drops
- **Basket comparison** — compare grocery costs across UK supermarkets
- **Market research** — analyse competitive pricing and product ranges
- **Deal alerts** — build notifications for Nectar deals and promotions
- **Shopping apps** — power product search and comparison features

### Notes

- Sainsbury's uses `data-testid` attributes and `.pt__cost` class selectors — these may change when the site redeploys
- The scraper uses multiple fallback strategies for price extraction to handle inconsistent DOM rendering
- Brand is inferred from the product name; own-brand detection covers "by Sainsbury's" and "Taste the Difference" ranges

# Actor input Schema

## `queries` (type: `array`):

List of product search queries (e.g. \["beans", "milk", "bread"])

## `maxResultsPerQuery` (type: `integer`):

Maximum number of products to return per search query

## `proxyConfiguration` (type: `object`):

UK residential proxies required — Sainsbury's blocks datacenter IPs.

## Actor input object example

```json
{
  "queries": [
    "baked beans",
    "whole milk",
    "sourdough"
  ],
  "maxResultsPerQuery": 10,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": "GB"
  }
}
```

# Actor output Schema

## `products` (type: `string`):

Dataset of scraped Sainsbury's product listings — each row contains name, brand, price, unitPrice, unitPriceMeasure, unitSize, onOffer, offerDescription, imageUrl, productUrl, gtin, and scrapedAt.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "queries": [
        "baked beans",
        "whole milk",
        "sourdough"
    ],
    "maxResultsPerQuery": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("illehius/sainsburys-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "queries": [
        "baked beans",
        "whole milk",
        "sourdough",
    ],
    "maxResultsPerQuery": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("illehius/sainsburys-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "queries": [
    "baked beans",
    "whole milk",
    "sourdough"
  ],
  "maxResultsPerQuery": 10
}' |
apify call illehius/sainsburys-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,illehius/sainsburys-scraper"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/Ymmy0ylyGzOTWIV0W/builds/FIoiglR5b5aQ9h13A/openapi.json
