Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # import libraries
- from bs4 import BeautifulSoup
- import urllib2
- import re
- import time
- # Import smtplib for the actual sending function
- import smtplib
- # Import the email modules we'll need
- from email.mime.text import MIMEText
- # specify the url
- quote_page = 'https://www.noelleeming.co.nz/shop/phones-and-gps/mobile-phones/iphone/c12704-cmobilephones-cappleiphones-p1.html?sorter=price-desc'
- me = "jarredogreen@gmail.com"
- while True:
- # query the website and return the html to the variable 'page'
- page = urllib2.urlopen(quote_page)
- # parse the html using beautiful soap and store in variable `soup`
- soup = BeautifulSoup(page, 'html.parser')
- if soup.findAll(text=re.compile('iPhone X')).count > 0:
- print("found iphone, emailing")
- # email me about new iphone
- server = smtplib.SMTP('smtp.gmail.com', 587)
- server.starttls()
- # Next, log in to the server
- server.login("jarred.o.green@gmail.com", "vifzwgzwqzvnkvey")
- # Send the mail
- msg = "CHECK NOEL LEEMINGS!"
- server.sendmail("jarredogreen@gmail.com", "jarredogreen@gmail.com", msg)
- server.quit()
- break
- else:
- # wait 5 minutes and try again
- print("sleeping")
- time.sleep(300)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement