Skip to main content

Israel Supermarket Scraper: Clients to download the data published by the supermarkets.

This is a scraper for ALL the supermarket chains listed in the GOV.IL site.

שקיפות מחירים (השוואת מחירים) - https://www.gov.il/he/departments/legalInfo/cpfta_prices_regulations

Unit & Integration Tests CodeQL Pylint Publish Docker image Upload Python Package

🤗 Want to support my work?

Buy Me A Coffee

Daily Automatic Testing

The test suite is scheduled to run daily, so you can see if the supermarket chains have changed something in their interface and the package will not work properly.

Status: Scheduled Tests

Notice:

  • Bareket and Quik are flaky! They will not fail the testing framework, but you can still use them.
  • Some of the scrapers sites are blocked from being accessed from outside of Israel.
  • Some chains (Victory, Mahsani Ashuk) have both a legacy source and a new API-based source. Use the _NEW_SOURCE variant (e.g. VICTORY_NEW_SOURCE, MAHSANI_ASHUK_NEW_SOURCE) if the primary scraper stops finding files.

Got a question?

You can email me at erlichsefi@gmail.com

If you think you've found a bug:

  • Create issue in issue tracker to see if it's already been reported
  • Please consider solving the issue by yourself and creating a pull request.

What is il_supermarket_scarper?

There are a lot of projects in GitHub trying to scrape the supermarket data, but most of them are not stable or haven't been updated for a while, it's about time there will be one codebase that does the work completely.

You only need to run the following code to get all the data currently shared by the supermarkets.

Simple disk-based scraping:

from il_supermarket_scarper import ScarpingTask

scraper = ScarpingTask()
scraper.start()

Async queue-based scraping (consume files as they are downloaded):

import asyncio
from il_supermarket_scarper import ScarpingTask, ScraperFactory
from il_supermarket_scarper.utils import _now

async def main():
    scraper = ScarpingTask(
        output_configuration={
            "output_mode": "queue",
            "queue_type": "memory",
        },
        status_configuration={"database_type": "json", "base_path": "status_logs"},
        multiprocessing=1,
        enabled_scrapers=[ScraperFactory.BAREKET.name, ScraperFactory.VICTORY_NEW_SOURCE.name],
    )

    scraper.start(limit=1, when_date=_now())

    async def consume_queue():
        for name, file_output in scraper.consume().items():
            async for msg in file_output.queue_handler.get_all_messages():
                file_name = msg["file_name"]
                file_content = msg["file_content"]
                file_link = msg["file_link"]
                metadata = msg["metadata"]
                print(f"[{name}] {file_name} ({len(file_content)} bytes)")

    await consume_queue()
    scraper.join()

asyncio.run(main())

Please notice! Since new files are constantly uploaded by the supermarket to their site, you will only get the current snapshot. In order to keep getting data, you will need to run this code more than one time to get the newly uploaded files.

Quick start

il_supermarket_scarper can be installed using pip:

python3 -m pip install il-supermarket-scraper

If you want to run the latest version of the code, you can install it from the repo directly:

python3 -m pip install -U git+https://github.com/OpenIsraeliSupermarkets/israeli-supermarket-scarpers.git
# or if you don't have 'git' installed
python3 -m pip install -U https://github.com/OpenIsraeliSupermarkets/israeli-supermarket-scarpers/main

Running Docker

The docker is designed to re-run against the same configuration, in every iteration the scraper will collect the files available to download and check if the file already exists before fetching it, either by scanning the dump folder, or checking the mongo/status files.

Build yourself:

docker build -t erlichsefi/israeli-supermarket-scarpers --target prod .

or pull the existing image from docker hub:

docker pull erlichsefi/israeli-supermarket-scarpers:latest

Then running it using:

docker run  -v "./dumps:/usr/src/app/dumps" \
            -e ENABLED_SCRAPERS="BAREKET,YAYNO_BITAN" \   # see: il_supermarket_scarper/scrappers_factory.py
            -e ENABLED_FILE_TYPES="STORE_FILE" \          # see: il_supermarket_scarper/utils/file_types.py
            -e FILE_NAME_REGEX="PriceFull.*" \            # optional regex matched against file names
            -e LIMIT=1 \                                  # number of files you would like to download (remove for unlimited)
            -e TODAY="2024-10-23 14:35" \                 # the date to download data from
            -e OUTPUT_MODE="disk" \                       # 'disk' (default) or 'queue' - where to save scraped files
            -e STORAGE_PATH="./dumps" \                   # (optional) custom storage path for disk mode
            erlichsefi/israeli-supermarket-scarpers

For queue output mode:

docker run  -e OUTPUT_MODE="queue" \
            -e QUEUE_TYPE="memory" \                      # 'memory' (for testing) or 'kafka'
            erlichsefi/israeli-supermarket-scarpers

For Kafka queue output:

docker run  -e OUTPUT_MODE="queue" \
            -e QUEUE_TYPE="kafka" \
            -e KAFKA_BOOTSTRAP_SERVERS="localhost:9092" \ # Kafka bootstrap servers
            erlichsefi/israeli-supermarket-scarpers

Environment Variables

The following environment variables can be used to configure the scraper:

General Configuration

  • ENABLED_SCRAPERS: Comma-separated list of scrapers to enable. See il_supermarket_scarper/scrappers_factory.py for all available scrapers. Current options include: BAREKET, YAYNO_BITAN_AND_CARREFOUR, COFIX, CITY_MARKET_KIRYATGAT, CITY_MARKET_SHOPS, DOR_ALON, GOOD_PHARM, HAZI_HINAM, HET_COHEN, KESHET, KING_STORE, MAAYAN_2000, MAHSANI_ASHUK, MAHSANI_ASHUK_NEW_SOURCE, NETIV_HASED, MESHMAT_YOSEF_1, MESHMAT_YOSEF_2, OSHER_AD, POLIZER, RAMI_LEVY, SALACH_DABACH, SHEFA_BARCART_ASHEM, SHUFERSAL, SHUK_AHIR, STOP_MARKET, SUPER_PHARM, SUPER_YUDA, SUPER_SAPIR, FRESH_MARKET_AND_SUPER_DOSH, QUIK, TIV_TAAM, VICTORY, VICTORY_NEW_SOURCE, YELLOW, YOHANANOF, ZOL_VEBEGADOL, WOLT
  • ENABLED_FILE_TYPES: Comma-separated list of file types to download (e.g., "STORE_FILE,PRICE_FILE"). See il_supermarket_scarper/utils/file_types.py for all available types.
  • FILE_NAME_REGEX: Regular expression matched against file names with re.search. If unset, all discovered files are eligible.
  • LIMIT: Maximum number of files to download (optional, no limit if not specified).
  • NUMBER_OF_PROCESSES: Number of parallel processes to use (default: 5).
  • TODAY: Date to download data from, in format "YYYY-MM-DD HH:MM" (e.g., "2024-10-23 14:35").

Output Configuration

  • OUTPUT_MODE: Where to save scraped files (default: "disk")
    • disk: Save files to local filesystem
    • queue: Send files to a message queue

Disk Output Mode (default)

  • STORAGE_PATH: Custom storage path for files (optional, uses default if not specified).

Queue Output Mode

  • QUEUE_TYPE: Type of queue to use (required when OUTPUT_MODE="queue")
    • memory: In-memory queue (useful for testing)
    • kafka: Apache Kafka message queue
Kafka Queue
  • KAFKA_BOOTSTRAP_SERVERS: Kafka bootstrap servers (default: "localhost:9092").

Contributing

Help in testing, development, documentation and other tasks is highly appreciated and useful to the project. There are tasks for contributors of all experience levels.

If you need help getting started, don't hesitate to contact me.

Development status

IL SuperMarket Scraper is beta software, as far as i see devlopment stoped until new issues will be found.

Metadata

Release files for il-supermarket-scraper 1.0.16

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for il-supermarket-scraper 1.0.16
File Size Uploaded
il_supermarket_scraper-1.0.16.tar.gz 97.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for il-supermarket-scraper 1.0.16
File Interpreter ABI Platform
il_supermarket_scraper-1.0.16-py3-none-any.whl Python 3 none any Details

Total release size: 222.0 kB

Release files / il_supermarket_scraper-1.0.16.tar.gz

Download URL il_supermarket_scraper-1.0.16.tar.gz
Size 97.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b97f6e6c09576e410767a9c6abc04a6ac9bfbd4ce6ffc4cc4fd4569c83757029
BLAKE2b-256 checksum
How to use checksums
ce83e07983d2212a6213f0a30d51a964d596631aef7ebbed9837056d78474373
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / il_supermarket_scraper-1.0.16-py3-none-any.whl

Download URL il_supermarket_scraper-1.0.16-py3-none-any.whl
Size 124.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5fd66e164acfdda71cf15f3ee0205b726f7c4a454ccb670ec5c3a6d04f44c808
BLAKE2b-256 checksum
How to use checksums
7382ed004d498126da4d72d216a80039433e52bfb47a5aedd8a3984a50d7e017
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release history Release notifications | RSS feed

This release

1.0.16 This release

2 release files

1.0.14

2 release files

1.0.13

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.6.7

2 release files

0.6.6

2 release files

0.6.5

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.9

2 release files

0.5.8

2 release files

0.5.7

2 release files

0.5.6

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.9

2 release files

0.4.8

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.1

2 release files

0.3

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2

2 release files

0.1

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page