Git Product home page Git Product logo

lego-restock-bot's Introduction

lego-restock-bot


Get informed when Lego shop products are available again.

This project uses scrapy to extract information from the German Lego shop page. It crawls products from the shop and scrapes their information. You can regularly run the scraping to check whether products are in stock again. In case of available products, you can send automatic Telegram messages to stay up to date.

Find the blog article about the project here: A Real-World Scrapy Tutorial - Python Lego Shop Restock Bot

Installation

Create a Python virtual environment and install dependencies:

python3 -m venv venv_lego
pip3 install -r requirements.txt

Searching Lego products

It's enough to run this command once. It will save crawled lego products to the SQLite database. Since the products rarely change, it's sufficient to run this sometimes manually.

scrapy crawl products

Update availability and prices of found products

For retrieving the availabilities of all products in the database, use the availability spider and pipelines. It will save the latest availability information in the database.

scrapy crawl availability

Generate Telegram notifications

In the .env file set the Telegram Bot token and the channel ID. The Bot needs to be administrator of the channel.

TELEGRAM_BOT_TOKEN=<bot token>
TELEGRAM_CHANNEL_ID=<channel ID>

In order to figure out the channel ID, send the channel invitation link to @username_to_id_bot

Automatic notifications

In case you want to get updates regularly, execute the script "update_availability.sh" in a cron job. In case you want to run the script every two hours add the following using crontab -e:

0 */2 * * * /<your full path>/update_availability.sh

Inside the bash script, configure the two variables with your corresponding paths:

VENV_PATH=""
SCRAPY_PROJECT_ROOT_DIR=""

lego-restock-bot's People

Contributors

chrizog avatar samvdjagt avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.