DEV Community

Cover image for How to Pull Carrefour Grocery Prices and Promotions with Python
ReventaData
ReventaData

Posted on Originally published at apify.com

How to Pull Carrefour Grocery Prices and Promotions with Python

Comparing grocery prices by hand is slow. By the end of this tutorial you will have a short Python script that pulls grocery products from carrefour.fr into structured rows: name, brand, EAN barcode, shelf price, price per litre or kilogram, promotion with its dates, and availability.

Carrefour France Scraper (reventadata/carrefour-scraper) is the Apify Actor built for this site. You give it search terms or category links, and it returns one row per product, read from public pages with no login.

Unofficial note: this Actor is not affiliated with, authorised by or endorsed by Carrefour. "Carrefour" is a trademark of its owner and is used only to describe the site the tool reads.

The sample row in this post is one row built from a real carrefour.fr listing page read on 20 November 2026. I did not edit any value in it, except scrapedAt, which shows the capture date instead of a run time.


Prerequisites

You need three things:

  1. Python 3.11 or newer with pip.
  2. A free Apify account. You can sign up with an email address or a GitHub login.
  3. Your Apify API token, which the script reads from an environment variable.

Install the client and export the token in the terminal you run the script from:

pip install -U "apify-client~=3.0"
export APIFY_API_TOKEN="your_apify_token_here"
Enter fullscreen mode Exit fullscreen mode

No scraping code is needed on your side. The Actor fetches the pages and returns the rows.


What you'll achieve

You will search carrefour.fr for one grocery term, keep only products that are on promotion, cap the run at fifty products and print one summary line per product from Python. The same script works for any keyword or category link. Only the input changes.

Each row carries the price of one unit in euros, the price per kilogram or litre as a number and as written on the page, and the promotion fields when the site shows one. You will see one full row in the output section, so you know which fields to expect before you write code that reads them.


Step-by-step guide

Step 1: Open the Actor

Open the Carrefour France Scraper page on the Apify Store. This tutorial calls the Actor from Python, so the only name you need is reventadata/carrefour-scraper.

For current pricing and details, see the Store page.

Step 2: Choose the input

The input is a JSON object. These fields matter most:

  • searchQueries: a list of keywords, one search each, written as you would type them in the site's search box.
  • categoryUrls: a list of category links, such as https://www.carrefour.fr/r/cremerie/laits, or just the path cremerie/laits. A link with a filter in it, such as a brand, works too.
  • onlyPromotions: true keeps only products that show a promotion or a struck-through price.
  • includeMarketplace: true by default. It includes products sold by outside sellers, shown with the seller name. Set it to false to keep Carrefour's own range.
  • minPrice and maxPrice: optional price bounds in euros.
  • sort: one of relevance (the default), priceAsc, priceDesc, unitPriceAsc, unitPriceDesc or ratingDesc.
  • maxItems: the total number of products to save across all searches and categories. The default is 100.
  • maxPagesPerListing: the number of pages of 30 products to read per keyword or category, from 1 to 99. The default is 99.

The run in this guide uses this input:

{
    "searchQueries": ["lait demi-ecreme"],
    "categoryUrls": ["https://www.carrefour.fr/r/cremerie/laits"],
    "onlyPromotions": true,
    "maxItems": 50
}
Enter fullscreen mode Exit fullscreen mode

Step 3: Run the Actor from Python

This script starts the Actor, waits for it to finish, reads the dataset and prints one summary line per product:

import os
from apify_client import ApifyClient

# 1. Initialise the client with your token from the environment
client = ApifyClient(os.environ["APIFY_API_TOKEN"])

# 2. Describe the search: one keyword and one category, promotions only, 50 products
run_input = {
    "searchQueries": ["lait demi-ecreme"],
    "categoryUrls": ["https://www.carrefour.fr/r/cremerie/laits"],
    "onlyPromotions": True,
    "maxItems": 50,
}

# 3. Start the Actor and wait for it to finish
run = client.actor("reventadata/carrefour-scraper").call(run_input=run_input)
if run is None or run.status != "SUCCEEDED":
    status = run.status if run else "unknown"
    raise SystemExit(f"Run did not succeed (status: {status}).")

# 4. Read the rows from the run's default dataset
items = client.dataset(run.default_dataset_id).list_items().items
print(f"Retrieved {len(items)} products.\n")

# 5. Print one line per product: name and brand, then price and unit price
for item in items:
    print(f"{item.get('name')} | {item.get('brand')} | {item.get('price')} EUR")
    print(f"  {item.get('unitPriceText')}, promotion: {item.get('promotionLabel')}")
Enter fullscreen mode Exit fullscreen mode

A run that finishes with a status other than SUCCEEDED stops the script with a message, as in step 3.

Step 4: Read one row

One row, built from page 2 of a search for lait, is shown below. Field names are as the Actor writes them, and null means the site shows no value:

{
  "id": "3560070435272",
  "ean": "3560070435272",
  "name": "Lait Demi-Ecrémé UHT Bio CARREFOUR BIO",
  "brand": "CARREFOUR BIO",
  "url": "https://www.carrefour.fr/p/lait-demi-ecreme-uht-bio-carrefour-bio-3560070435272",
  "price": 0.95,
  "currency": "EUR",
  "originalPrice": null,
  "unitPrice": 1.9,
  "unitOfMeasure": "L",
  "unitPriceText": "1.90 € / L",
  "promotionLabel": "-10% Club",
  "promotionStartsAt": "2025-01-01T00:00:00+0100",
  "promotionEndsAt": "2026-12-31T23:59:00+0100",
  "promotionMinQuantity": null,
  "promotionPriceForQuantity": null,
  "promotionIsLoyalty": true,
  "available": true,
  "lowStock": false,
  "packaging": "la bouteille 50cL",
  "format": "50cl",
  "categoryPath": [
    "Crèmerie et Produits laitiers",
    "Laits et Boissons végétales",
    "Lait demi-écrémé"
  ],
  "rating": 4.9,
  "reviewCount": 58,
  "nutriscore": null,
  "isMarketplace": false,
  "seller": null,
  "offerId": "0261-150-6",
  "source": "search",
  "sourceValue": "lait",
  "page": 2,
  "scrapedAt": "2026-11-20T00:00:00+00:00"
}
Enter fullscreen mode Exit fullscreen mode

The row also carries the product image links, the category link, the seller id and the sponsored and new-product flags, which are left out of this sample to keep it short.


Understanding your results

The fields fall into four groups.

Identity. ean is the barcode, the field to join on across shops and datasets. id falls back to the site's product id when there is no barcode.

Price. price is the price of one unit in euros. When the site shows a struck-through price, price is the reduced price and originalPrice holds the one before it. In the sample above the shelf price is 0.95 EUR and the unit price is 1.90 EUR per litre, because the bottle holds 50 cl. The unit price is the number to compare across pack sizes.

Promotion. promotionLabel is the text as the site writes it, for example Le 2eme a -50%. promotionStartsAt and promotionEndsAt are ISO 8601 dates. promotionMinQuantity and promotionPriceForQuantity give the units to buy in a multi-unit offer and their total price. promotionIsLoyalty is true for a loyalty-card offer.

Source and seller. source says whether the product came from a search or a category, sourceValue holds the keyword or the category path, and page is the page it came from. isMarketplace is true for an outside seller, whose name is in seller. offerId tells two offers for one product apart.


Pro tips and advanced usage

  • Narrow the page count for quick tests. maxPagesPerListing caps how many pages of 30 products each are read per keyword or category. Set it to 1 while you build the script.
  • Filter in the Actor, then in Python. onlyPromotions, includeMarketplace, minPrice and maxPrice are applied after the pages are read. A strict filter therefore reads more pages for the same number of products. Keep maxPagesPerListing at a value that fits the listing you want.
  • Sort by unit price. Set sort to unitPriceAsc to see the cheapest price per litre or kilogram first. That is the order to use when you compare pack sizes.
  • Save the rows while you work on the script. Write the dataset to a local JSON file once, then read that file while you change your code. Each new run uses platform credit, so you pay for the run only when you need fresh data.
  • Keep your own range. Set includeMarketplace to false when you only want Carrefour's own products.

Troubleshooting common issues

  • The run ends with a message about a search term. The site refuses a search term of one letter. Use a longer word, such as lait.
  • The run ends with a message about a category. The category link is not one the site knows. Copy the address from a category page on carrefour.fr and paste it into categoryUrls.
  • The log warns that a listing is too large. The site serves at most 99 pages, which is 2,970 products, for one search or category. Narrow the search with a more specific keyword or a sub-category.
  • You get fewer rows than maxItems. The listing may hold fewer matching products, or the filters may have removed them.
  • The dataset is empty but the run succeeded. Nothing matched the filters. Remove onlyPromotions or widen the price bounds.

If a run fails, its log says why.


Next steps

Try a second search, or a category of your own choice, and compare the unit prices in the two results. Once the script works, you can write the rows to a CSV file, load them into a spreadsheet, or keep a history by saving one run per week. Each of these uses the same input and the same dataset read.

Experiment with the sort order and the promotion filter. What are you planning to track? Drop a comment below.

Top comments (0)