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

Commit 3dcdc87

Browse files
price_tracker
1 parent 84513bb commit 3dcdc87

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

‎price_tracker/amazonprice.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import requests
2+
from bs4 import BeautifulSoup
3+
import time
4+
import smtplib
5+
6+
#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"
8+
#}
9+
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"
11+
12+
# get your browser information by searching "my user agent"
13+
user_agent = input("Enter your User-Agent string here\n")
14+
headers = {
15+
"User-Agent": f'{user_agent}'
16+
17+
}
18+
Url = input("Drop the Url of product you wish to buy...!\n")
19+
20+
page = requests.get(Url, headers=headers)
21+
soup = BeautifulSoup(page.content, "html.parser")
22+
# print(soup)
23+
y_price = (input('Enter the price you wish to get the product at:'))
24+
your_price = y_price.replace(',', '')
25+
26+
27+
def mail_sending(Id, title):
28+
server_mail = "smtp.gmail.com"
29+
port = 587
30+
mail_id = "mallickmadiha9031@gmail.com"
31+
password = "meaclqmbilrljtbm"
32+
server = smtplib.SMTP(server_mail, port)
33+
server.ehlo()
34+
server.starttls()
35+
server.login(mail_id, password)
36+
subject = "GO BUY FAST!"
37+
body = f"Price of {title} is fallen below the threshold amount. Click on the link below to buy the product\n\n" + Url
38+
message = f'Subject:{subject}\n\n {body}'
39+
server.sendmail(mail_id, Id, message)
40+
server.quit()
41+
42+
43+
def check_price(your_price):
44+
title = soup.find(id="productTitle").get_text().strip()
45+
price = soup.find(id="priceblock_ourprice_row").get_text().strip()[:20].replace('₹', '').replace(' ', '').replace(
46+
'Price:', '').replace('\n', '').replace('\xa0', '').replace(',', '').replace('Fu','')
47+
fixed_price = float(price)
48+
print(title)
49+
print(f'The current price is {fixed_price}')
50+
Id = input("Please enter your email id: ")
51+
print("Thank You! You'll receive an email as soon as the price of product drops...!")
52+
# print(price)
53+
if fixed_price <= float(your_price):
54+
mail_sending(Id, title)
55+
exit()
56+
else:
57+
pass
58+
59+
60+
while 1:
61+
check_price(your_price)
62+
# checks at an interval of 2 hours
63+
time.sleep(7200.00)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /