Amazon Code FR Price
Amazon Code FR Price
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import requests,time,smtplib
from bs4 import BeautifulSoup
from notify_run import Notify
from datetime import datetime
url = "https://www.amazon.in/Philips-Trimmer-Cordless-QT4001-15/dp/B00L8PEEAI/
ref=sr_1_4?
crid=26OVQAIRQLJUU&keywords=philips+qt4011%2F15&qid=1569507835&s=hpc&sprefix=philip
s+qt%2Chpc%2C361&sr=1-4"
dp = 1000
URL = url
headers = {"User-Agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36'}
soup= BeautifulSoup(page.content,'html.parser')
title = soup.find(id="productTitle").get_text()
price = soup.find(id="priceblock_ourprice").get_text()
main_price = price[2:]
#LETS MAKE IT AN
INTEGER---------------------------------------------------------------
l = len(main_price)
if l<=6 :
main_price = price[2:5]
else:
p1 = price[2]
p2 = price[4:7]
pf = str(p1)+str(p2)
main_price = int(pf)
price_now = int(main_price)
title1=str(title.strip())
main_price1 = main_price
pnmsg = "Rs. "+str(main_price1)+" for "+title1
'''
print(title.strip())
print(price.strip())
print(main_price)
print(real_price)
print(type(real_price))
print(dp)
print(type(dp))
'''
#FUNCTION TO CHECK THE PRICE-------------------------------------------------------
def check_price():
count = 0
if(price_now <= dp):
send_mail()
push_notification()
else:
count = count+1
print("Rechecking... Last checked at "+str(datetime.now()))
def send_mail():
server = smtplib.SMTP('smtp.gmail.com',587)
server.ehlo()
server.starttls()
server.ehlo()
server.login('[email protected]','fzanpwfvxnldiycv')
subject = "Price of "+title1+" has fallen down to Rs. "+str(main_price1)
body = "Hey Amlan! \n The price of "+title1+" on AMAZON has fallen down to
Rs."+str(main_price1)+", which is less than your desired price of Rs."+str(dp)+".\n
So, hurry up & check the amazon link right now : "+url
server.sendmail(
'[email protected]',
'[email protected]',
msg
)
print("HEY AMLAN, EMAIL HAS BEEN SENT SUCCESSFULLY.")
server.quit()
#Now let's send the push
notification-------------------------------------------------
def push_notification():
notify = Notify()
notify.send(pnmsg)
print("HEY AMLAN, PUSH NOTIFICATION HAS BEEN SENT SUCCESSFULLY.")