This project notifies you about current offers from the German electronics retail chains Saturn and MediaMarkt in their Fundgrube, that match specific conditions you can define.
Before you start make sure python 3.9 (or higher) and poetry are installed on your machine.
First, clone the project, navigate to its root directory, and install the dependencies (this automatically creates a virtual environment):
poetry install
Next, rename the file sample_products.json
in the data
directory to products.json
and fill it as specified in the Options section.
If you want to get email notifications, the easiest way is to use a Google account (for Gmail)
with 2FA enabled.
In your account you have to generate an app password for Gmail.
While creating the password select "Mail" as app and "Other" as device (select as custom name you see fit, e.g., "Raspberry Pi").
We need to use app passwords (which in turn require 2FA) due to a policy change in mid-2022.
Lastly, you have to rename the sample.env
to .env
and fill it as follows:
MAIL_SENDER
The gmail address you want to send the emails from.MAIL_PASSWORD
The 16-digit app password you generated.MAIL_RECEIVER
If you want to receive the emails on another address, set it here. (Optional)
If you do not want to use Gmail you also have to specify:
SMTP_SERVER
The SMTP server of your email provider.SMTP_PORT
The corresponding SMTP port.
Be aware though, that non-Gmail approaches might run into issues with 2FA etc. and were not tested.
Once everything is set up, you can run the script with
poetry run python fundgrube_notifier.py
You can also set up a cron job (or something similar) to automatically execute the script every hour. For this, open the cron tab with
crontab -e
and then add the following line to configure the cron job (replace <path>
with the path to this project's root directory):
5 8-23 * * * cd <path>/fundgrube-notifier && poetry run python fundgrube_notifier.py
Make sure that cron has access to the correct $PATH
(e.g., for poetry), by copying the following line above the definition of the cron job (replace <user>
with your device's username):
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/home/<user>/.local/bin
See this Stack Overflow post for more details regarding cron and $PATH
.
Entries in the products.json
file are created in JSON format and every JSON object can have the following attributes to filter the available articles:
- include: A list of terms that must appear in the name of the article (case-insensitive;
AND
operator). (Mandatory).- Also accepts lists of terms instead of terms, of which only one term has to match (
OR
operator; see example).
- Also accepts lists of terms instead of terms, of which only one term has to match (
- exclude: A list of terms, that must not appear in the name of the article (case-insensitive). (Optional)
- price: Articles with a higher price are ignored. (Optional)
- store: A list of terms, that must appear in the name of the store (case-insensitive). (Optional)
When choosing the terms for include
, exclude
, and store
, remember that only simple string matching is done, so sometimes only using substrings might be beneficial.
fundgrube-notifier/data/sample_products.json
Lines 1 to 11 in 8a3bad4
The Fundgrube has special offers that are usually very limited in numbers and can be found here:
- Saturn: https://www.saturn.de/de/data/fundgrube
- MediaMarkt: https://www.mediamarkt.de/de/data/fundgrube
This project is using already preprocessed data, which is crawled hourly by a script from Barney at mydealz:
- Saturn: https://schneinet.de/saturn.html
- MediaMarkt: https://schneinet.de/mediamarkt.html