Albert Heijn product data without an API

Price, unit price, size, category, ingredients and nutrition from ah.nl product pages, as one tidy row per product. Learned from real product pages and tested on every one.

Albert Heijn product data

ah.nl/producten/product/wi2390/…
name
Bonne Maman Aardbeien confiture
price
3.39
size
370 g
unit price
€ 9,16
category
Aardbeienjam
energy
1.023 kJ (241 kcal)
sugars
59 g

Nederlands

What comes out of Albert Heijn pages

Tested on 23 real Albert Heijn pages: 72 of 83 values exactly right, 0 wrong. When it isn't sure, it says so instead of guessing. Fields it pulls:

  • brand
  • category
  • main category
  • protein
  • energy
  • barcode (GTIN)
  • ingredients
  • kcal (recipes)
  • carbohydrates
  • name
  • price
  • rating (recipes)
  • servings (recipes)
  • size
  • product number
  • storage
  • sugars
  • supplier
  • cooking time (recipes)
  • fat
  • salt

Left empty on some test pages, not filled in wrong. A few more example pages with these values, and the rules for them get learned too:

  • brand · 2 empty
  • category · 3 empty
  • main category · 3 empty
  • ingredients · 1 empty
  • unit price · 2 empty

Is there an Albert Heijn API for product data?

Not an open, documented one you can sign up for. What people use instead: the JSON the shop's own app or site loads (undocumented, it changes without notice, and the terms may not allow it), the structured data in the product pages themselves, or the visible text. An extraction script reads the pages you are allowed to fetch, the same way a browser does, and says when the layout changed.

How to scrape Albert Heijn product pages without an AI

  1. Check the page source first. Product pages often carry name, price and stock as JSON-LD. If view source shows the price, a plain HTTP request is enough: no headless browser.

  2. Fetch only what changed. Read the sitemap and skip every page whose lastmod hasn't moved since the last run.

  3. Go slow. One request every second or two, a clear User-Agent, and nothing behind a login. A supermarket site is not a test server.

  4. Learn the rules once. Every product page of one shop shares a structure. Send a few and get a rule per field, tested on all of them: price, unit price, size, category.

The traps on supermarket pages

  1. Split prices. The euros and the cents sit in two elements (2 and 69), so a simple selector reads "2" or "269".

  2. The old price next to the new one. A promotion shows both. The rule has to pick the price you pay, not the struck-through one.

  3. Related products. The page lists other products with their own prices. The first price on the page is often not this product's.

  4. Class names that change every deploy. Hashed CSS classes break hand-written selectors after each release. Rules learned from several pages lean on what stays.

More on this

Try it on your own pages

Paste a few links and a couple of values. The look is free, and you hear the price before anything is due.

Try it on your pages