How to Scrape Sainsbury's Grocery Prices with Python
Описание и применение
Скрипт на Python, использующий Apify, извлекает цены и акции товаров из онлайн‑каталога Sainsbury's, возвращая структурированные JSON‑данные.
Задача
Tracking grocery prices or checking promotional discounts by hand across dozens of products is tedious and time‑consuming.
Результат
The benchmark run with searchQueries:["coffee"], maxItems:60, maxPages:3, onlyPromotions:true, exactMatchesOnly:true finished in 10.6 seconds and returned 50 products.
Рабочий процесс
- Install Python 3.11+ and the Apify API client via pip.
- Create an Apify account and obtain an API token.
- Write a Python script that initializes an ApifyClient with the token.
- Define run_input with searchQueries, maxItems, maxPages, onlyPromotions, exactMatchesOnly, and proxyConfiguration.
- Call the Sainsbury's Scraper actor using client.actor(...).call(run_input=run_input).
- Iterate over the resulting dataset with client.dataset(run.default_dataset_id).iterate_items() and print or process each item.
- Optionally download the dataset from the Apify Console as JSON, CSV, Excel or JSONL.
Доказательства
By the end of this tutorial, you will have a Python script that pulls grocery prices and promotional offers from Sainsbury's into structured JSON: product name, shelf price in GBP, Nectar card price, promotional text, unit price and unit measure, customer rating, category names, EAN barcodes, and product URL.
Our benchmark run (configured with searchQueries: ["coffee"], maxItems: 60, maxPages: 3, onlyPromotions: true, exactMatchesOnly: true) finished in 10.6 seconds and returned 50 products.
The scraper reads product records embedded directly in search results, so individual product pages do not need to be opened separately.
- Дата записи: 2026-10-23T22:11:30.517Z