Skip to main content

python package that implement a scraping for israeli supermarket data

Project description

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:

  • Berekt 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.

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.

from il_supermarket_scarper import ScarpingTask

scraper = ScarpingTask()
scraper.start()

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 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 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 (e.g., "BAREKET,YAYNO_BITAN"). See il_supermarket_scarper/scrappers_factory.py for all available scrapers.
  • 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.
  • 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

il_supermarket_scraper-1.0.1.tar.gz (71.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

il_supermarket_scraper-1.0.1-py3-none-any.whl (96.3 kB view details)

Uploaded Python 3

File details

Details for the file il_supermarket_scraper-1.0.1.tar.gz.

File metadata

  • Download URL: il_supermarket_scraper-1.0.1.tar.gz
  • Upload date:
  • Size: 71.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for il_supermarket_scraper-1.0.1.tar.gz
Algorithm Hash digest
SHA256 82827420258ce0e2d9faaa2091026c3fe39058aeb458d11910f4ddb4caa1071b
MD5 06eea20c13c34db6fc0e499626ae6e44
BLAKE2b-256 738acb450909657624c2cc1c29e40a5814292e0cd2ec239a51fd3c72252b9fbb

See more details on using hashes here.

File details

Details for the file il_supermarket_scraper-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for il_supermarket_scraper-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5620896ed455581bd1ea549f1d6ffe56e0d0129cc34319793e9a3fe036a41af5
MD5 958d7d8f0f806577081306c39e91df37
BLAKE2b-256 8dd761cf0725ece6ecad7071a28fd09c6dffadc5b66d6b36b9f4c4637c5e2aa9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page