Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
435
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. # import libraries
  2. from bs4 import BeautifulSoup
  3. import urllib2
  4. import re
  5. import time
  6.  
  7. # Import smtplib for the actual sending function
  8. import smtplib
  9.  
  10. # Import the email modules we'll need
  11. from email.mime.text import MIMEText
  12.  
  13. # specify the url
  14. quote_page = 'https://www.noelleeming.co.nz/shop/phones-and-gps/mobile-phones/iphone/c12704-cmobilephones-cappleiphones-p1.html?sorter=price-desc'
  15.  
  16. me = "jarredogreen@gmail.com"
  17.  
  18.  
  19. while True:
  20.  
  21. # query the website and return the html to the variable 'page'
  22. page = urllib2.urlopen(quote_page)
  23.  
  24. # parse the html using beautiful soap and store in variable `soup`
  25. soup = BeautifulSoup(page, 'html.parser')
  26.  
  27. if soup.findAll(text=re.compile('iPhone X')).count > 0:
  28. print("found iphone, emailing")
  29. # email me about new iphone
  30.  
  31. server = smtplib.SMTP('smtp.gmail.com', 587)
  32. server.starttls()
  33.  
  34. # Next, log in to the server
  35. server.login("jarred.o.green@gmail.com", "vifzwgzwqzvnkvey")
  36.  
  37. # Send the mail
  38. msg = "CHECK NOEL LEEMINGS!"
  39. server.sendmail("jarredogreen@gmail.com", "jarredogreen@gmail.com", msg)
  40. server.quit()
  41. break
  42. else:
  43. # wait 5 minutes and try again
  44. print("sleeping")
  45. time.sleep(300)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement