Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- A simple webpage monitor
- Author: Samuel Pell
- """
- import requests as req
- import sys
- import smtplib
- from email.mime.text import MIMEText
- USER = "" #put sender email here //it assumes you are using gmail
- URL = "https://www.hoyts.co.nz/movies/coming_soon.aspx"
- PASSWORD = "" #password for the email account
- SEARCH_TERM = "fireworks"
- def get_page(url):
- try:
- response = req.request('GET', url)
- return response.content
- except req.exceptions.ConnectionError:
- sys.exit("Error")
- def send_email():
- msg = MIMEText("""The word {} has been found on the Hoyts Coming Soon page
- - With Love,
- Bot-chan""".format(SEARCH_TERM.title()))
- msg['From'] = #put sender email here
- msg['Subject'] = "!!{} Alert!!".format(SEARCH_TERM.title())
- msg['To'] = ''#put recipient email here
- s = smtplib.SMTP(host='smtp.gmail.com', port=587)
- s.starttls()
- s.login(USER, PASSWORD)
- s.send_message(msg)
- s.quit()
- def main():
- web_page = get_page(URL)
- web_page = str(web_page).lower()
- isFound = web_page.find(SEARCH_TERM);
- if isFound != -1:
- print("Search term was found, sending email...")
- send_email()
- print("email sent :)")
- else:
- print("Search term was not found :(")
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement