Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import bs4
- from bs4 import BeautifulSoup
- import smtplib
- global url
- #url = "https://www.amazon.in/BassHeads-162-Secure-Braided-Earphones/dp/B07KXR889N/ref=sr_1_10?crid=URVJNBQLGUQY&keywords=boat+earphones+with+mic+and+bass&qid=1577558308&sprefix=boat+ea%2Caps%2C357&sr=8-10"
- global ant
- def main(url):
- #url = "https://www.amazon.in/BassHeads-162-Secure-Braided-Earphones/dp/B07KXR889N/ref=sr_1_10?crid=URVJNBQLGUQY&keywords=boat+earphones+with+mic+and+bass&qid=1577558308&sprefix=boat+ea%2Caps%2C357&sr=8-10"
- #url = input("Enter the url for your desired product")
- params = {
- "User-Agent" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36"
- }
- r = requests.get(url, headers = params)
- print(r.content)
- soup = BeautifulSoup(r.content , features = "html5lib")
- #print(soup)
- price = soup.find(id = "priceblock_ourprice")
- print(price)
- p = price.text[2:]
- global a
- a = float(p)
- print(a)
- #wanted_price = 200
- global email
- def sendmail(email):
- server = smtplib.SMTP("smtp.gmail.com", 587)
- server.ehlo()
- server.starttls()
- server.ehlo()
- server.login("tg3567.sc@gmail.com","candyeqdfldmyjao")
- subject = "Prices Dropped"
- body = "The price for your desired product has been dropped!!! \n"
- msg = "Subject:\n {}\n{} : ".format(subject,body)
- server.sendmail("tg3567.sc@gmail.com","sidchaturvedi.2000@gmail.com",msg)
- server.quit()
- def final(email,price):
- mail = email
- #wanted_price = 200
- if price < a:
- sendmail(mail)
- print("Email sent Succesfully")
- #main()
- #final("sidchaturvedi.2000@gmail.com",300 )
Add Comment
Please, Sign In to add comment