Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Python script to monitor a product and send notification on telegram on price drop.

License

NotificationsYou must be signed in to change notification settings

jadia/amazon-price-notify

Repository files navigation

A Python application to monitor an Amazon.in product and send notification through telegram on price drop.

The application has two parts:

  1. Monitor price
  2. Send notification

Monitor price:

Requests and Beautifulsoup modules are used to scrape the page and get the product title and it's price. The product page is scrapped every 15 min.

Send notification:

Generate a price drop alert to user via Telegram API usingpython-telegram-bot module.

Installation

Install on Local machine

Install dependencies (debian/ubuntu):

sudo apt-get -y install python3-pip&& \sudo pip3 install -r requirements.txt

The script was tested on Python 3.7.3.

Refer official telegram documentaion onHow to create a new bot

Put thebotToken generated from @botFather inconfig.json and runmain.py.

python3 ./main.py

botToken: Token given by botFather when new bot is created.

Set-up on Heroku

Create an account on Heroku and installHeroku CLI

curl https://cli-assets.heroku.com/install.sh| sudo sh

Login into Heroku

sudo heroku login

Goto heroku website and create anew app. Note down the name of application when you create it. It will be used in below commands.

Clone this repository

git clone https://github.com/th3nyx/amazon-price-notify.git&& \cd amazon-price-notify&& \heroku git:remote -a YOUR-HEROKU-APPLICATION-NAME

Deploy your application and watch logs:

sudo git add.&& \sudo git commit -am"make it better"&& \sudo git push heroku master&& \heroku logs --tail

NOTE: Heroku free account kills the container after half an hour. Add your heroku application toUptimeRobot to keep it alive.

As of 2019-08-26: Heroku only allows 550hrs/month for free accounts without credit card verification.

Usage

telegram bot screenshot

Search for your bot on telegram and start conversation.

/start: Bot sends you an introduction
/add: Add your product
/alert: Create alert

Demo

Visitamazon-price-tracker-bot.herokuapp.com to spin up the heroku application if it's dead.
Search fortestbot13371 on Telegram and start the conversation.

Note:The test bot should work if Amazon.in haven't changed their HTML tags

To-do

  • Use classes and object to support multiple products later.
  • Use Threads to track multiple items on watch.
  • Enable user to provide link directly from telegram app.
  • Accept all kinds to URL
  • Type checking of input data.
  • Heroku integration.
  • Overwrite old product when new product is added
  • Randomize User-Agent to avoid IP ban from Amazon.
  • Add cooldown timer once notification is sent.
  • Add snooze command to stop notifications for that many hours.
  • Exception handeling.
  • Introduce database to stop the links, so server restart or script crash won't affect the links.

Future Work:

  • Create a telegram menu and inlineKeyboard to replace commands.
  • Support for multiple products per customer.

Known-Issues

  1. If price of product is below threshold for more than 15 min. There will be multiple notifications.
  2. Incorrect URL hangs the application. (FIXED)

About

Python script to monitor a product and send notification on telegram on price drop.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp