Skip to content

Commit 43338ae

Browse files
Merge pull request #1582 from PrathmeshN99/master
Updated Amazon-Price-Tracker
2 parents 8bbe519 + 6bd4fc4 commit 43338ae

File tree

4 files changed

+30
-39
lines changed

4 files changed

+30
-39
lines changed

Amazon-Price-Tracker/README.MD

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<h1 align="center"> Amazon Price Tracker</h1>
2-
Tracks the current given product price.
2+
Tracks the current given product price and provides alerts on price drop on email and whatsapp.
33

44
---------------------------------------------------------------------
55

@@ -8,15 +8,16 @@ Tracks the current given product price.
88
- bs4 (BeautifuSoup)
99
- time
1010
- smtplib
11+
- pywhatkit
12+
- datetime
1113

12-
[requirements.txt]()
14+
[requirements.txt](Amazon-Price-Tracker/requirements.txt)
1315
<hr>
1416

1517
## How it works
1618
- By providing the User agent name and URL of the product that you want to track and buy and then it scrap the web and it
1719
tracks your product price.
18-
19-
- It returns The Tracking price of your product and it sends email when your product price decreases
20+
- It returns The Tracking price of your product and it sends email and whatsapp message when your product price decreases
2021
at best least price.
2122

22-
#### By [Avinash Kr. Ranjan](https://github.com/avinashkranjan)
23+
#### By [Avinash Kr. Ranjan](https://github.com/avinashkranjan)

Amazon-Price-Tracker/amazonprice.py

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22
from bs4 import BeautifulSoup
33
import time
44
import smtplib
5+
import pywhatkit
6+
import datetime
57

68
# header = {
7-
# "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36"
9+
# "
10+
# Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36
11+
# "
812
# }
913

10-
# Url = "https://www.amazon.in/Apple-AirPods-Wireless-Charging-Case/dp/B07QDRYVCZ/ref=sr_1_1_sspa?crid=2O0YQXVBL4T86&dchild=1&keywords=airpods&qid=1601031081&sprefix=airpod%2Caps%2C615&sr=8-1-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUFPVUpPNUNIQUE1RUUmZW5jcnlwdGVkSWQ9QTAxNzI3NjJPNlg3OTJFSTVSOE8mZW5jcnlwdGVkQWRJZD1BMDg1MTYzNjJSRUw4VFVKQzQ1TDkmd2lkZ2V0TmFtZT1zcF9hdGYmYWN0aW9uPWNsaWNrUmVkaXJlY3QmZG9Ob3RMb2dDbGljaz10cnVl"
14+
# Url = "
15+
# https://www.amazon.in/Apple-Original-MMTN2ZM-Lightning-Connector/dp/B01M1EEPOB/ref=sr_1_1?crid=XFITOYOGI999&keywords=airpods+apple&qid=1685422019&s=electronics&sprefix=airpods+appl%2Celectronics%2C458&sr=1-1
16+
# "
1117

1218
# get your browser information by searching "my user agent"
1319
user_agent = input("Enter your User-Agent string here\n")
@@ -20,6 +26,11 @@
2026
# print(soup)
2127

2228

29+
def message_sending(phone_number,title):
30+
now = datetime.datetime.now()
31+
message = f"Price of {title} is fallen below the threshold amount. Click on the link below to buy the product!!!\n\n"
32+
pywhatkit.sendwhatmsg(phone_number, message, now.hour, now.minute + 1)
33+
2334
def mail_sending(mail_id, title, password):
2435
server_mail = "smtp.gmail.com"
2536
port = 587
@@ -37,53 +48,28 @@ def mail_sending(mail_id, title, password):
3748
def check_price():
3849
title = soup.find(id="productTitle").get_text().strip()
3950
try:
40-
price = soup.find(
41-
id="priceblock_ourprice_row").get_text().strip()[:20].replace(
42-
'₹', '').replace(' ', '').replace('Price:', '').replace(
43-
'\n', '').replace('\xa0',
44-
'').replace(',', '').replace('Fu', '')
51+
price = price = soup.find('span', class_='a-price-whole').text
52+
price = price[:len(price)-1]
4553

4654
except:
47-
try:
48-
price = soup.find(
49-
id="priceblock_dealprice").get_text().strip()[:20].replace(
50-
'₹', '').replace(' ', '').replace('Price:', '').replace(
51-
'\n', '').replace('\xa0',
52-
'').replace(',',
53-
'').replace('Fu', '')
54-
55-
except:
56-
try:
57-
price = soup.find(
58-
id="priceblock_ourprice").get_text().strip()[:20].replace(
59-
'₹',
60-
'').replace(' ', '').replace('Price:', '').replace(
61-
'\n',
62-
'').replace('\xa0',
63-
'').replace(',', '').replace('Fu', '')
64-
65-
except:
66-
price = soup.find(id="priceblock_ourprice_lbl").get_text(
67-
).strip()[:20].replace('₹', '').replace(' ', '').replace(
68-
'Price:',
69-
'').replace('\n',
70-
'').replace('\xa0',
71-
'').replace(',',
72-
'').replace('Fu', '')
55+
print("Object out of stock or removed")
56+
return
7357

74-
fixed_price = float(price)
58+
fixed_price = float(price.replace(",", ""))
7559
print(title)
7660
print(f'The current price is {fixed_price}')
7761
y_price = (input('Enter the price you wish to get the product at:'))
7862
your_price = y_price.replace(',', '')
7963
mail_id = input("Please enter your email id: ")
8064
password = input("Enter your app password here: ")
65+
phone_number = input("Please enter your phone number: ")
8166
print(
8267
"Thank You! You'll receive an email as soon as the price of product drops...!"
8368
)
8469
# print(price)
8570
if fixed_price <= float(your_price):
8671
mail_sending(mail_id, title, password)
72+
message_sending(phone_number, title)
8773
exit()
8874
else:
8975
pass

Amazon-Price-Tracker/requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
requests==2.27.1
2+
bs4==0.0.1
3+
pywhatkit==5.4
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://www.amazon.in/Apple-Original-MMTN2ZM-Lightning-Connector/dp/B01M1EEPOB/ref=sr_1_1?crid=XFITOYOGI999&keywords=airpods+apple&qid=1685422019&s=electronics&sprefix=airpods+appl%2Celectronics%2C458&sr=1-1

0 commit comments

Comments
 (0)