How to Scrape Sainsbury's Grocery Prices with Python
说明与用途
使用 Apify 的 Python 脚本从 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