Skip to main content

Python Check for Change

· 3 min read
Phillip Passmore

The chip shortage last year meant getting hold of a Raspberry Pi from an official supplier was next to impossible.

About The Project#

To make sure I had the opportunity to pick up a Raspberry Pi 4 or Pi Zero 2 when they next go into stock, I started this quick project. The check for change is a simple project that takes the visable text of the webpage and compares to the previous version, if a change has taken place and the item is in stock then the python script notifies via text message.

Key goals of this project:

  • Only notifies if the product is in stock
  • Send a text message alert
  • To be run regularly on a Raspberry Pi

Built With#

This project has been built with Requests to get a copy of the webpage and Beautiful Soup to get the visible text. When a targeted item is in stock the Vonage Communications API is used to send text messages to alert that an item is in stock.

Getting Started#

To get set up, I have cloned the repo onto a Raspberry Pi, and added as Cron job to run checkforchange.sh.

The Cron job is set to run every 30 minutes with: /30 * * *

You will need to create an account with Vonage and set up the communication API. You will need the secret and key for the API. Vonage has been selected as they provide €2 free credit, without a payment method required, and each text costs €0.04.

Once the repo is cloned onto the Raspberry Pi you will need to manually run the main.py script, which will on first run ask for the API information and phone number. This information will be added to the newly created config.ini file. If any details need to be updated in future, you can edit them in the config.ini file.

[Vonage API]

  • key =
  • secret =
  • countrycode =
  • phonenumber =

Prerequisites#

Install the required packages using:

pip install -r requirements.txt

The provided requirements will install the following:

  • vonage>=2.0.0
  • configparser>=5.0.2
  • beautifulsoup4>=4.9.0
  • requests>=2.25.0

Installation#

  1. Get a free API Key at Vonage
  2. Clone the repo
    git clone https://github.com/Dr-Passmore/Check-for-change.git
  3. Install required packages
    pip install -r requirements.txt
  4. Run main.py and enter your API Key, secret, and phone number in the prompts
  5. Set up Cron job

Usage#

The script enables text alerts when items are in stock. The targets can be updated or changed. The only two key bits of info you need is a URL and a target phrase (Normally some version of "in Stock"). This means the script can be used for other websites and does not need to be Raspberry pi focused.