Advertisement
Guest User

Untitled

a guest
Feb 19th, 2016
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.08 KB | None | 0 0
  1. import smtplib
  2. import html5lib, lxml, lxml.cssselect
  3. import requests
  4.  
  5.  
  6. def scrape_registrar():
  7.     url = 'http://www.registrar.ucla.edu/schedule/detselect.aspx?termsel=16S&subareasel=STATS&idxcrs=0100A+++'
  8.     r = requests.get(url)
  9.     raw_html = r.text
  10.     page = html5lib.parse(raw_html, )
  11.  
  12.  
  13. def send_email(from_user, gmail_user, gmail_pass, to_user, subject, text):
  14.     # from user is single string, to_user is a list of strings
  15.  
  16.     message = 'Subject: %s\n\n%s' % (subject, text)
  17.  
  18.     try:
  19.         server = smtplib.SMTP('smtp.gmail.com',587)
  20.         server.ehlo()
  21.         server.starttls()
  22.         server.ehlo()
  23.         server.login(gmail_user, gmail_pass)
  24.         server.sendmail(from_user, to_user, message)
  25.         print('Email sent successfully')
  26.         server.quit()
  27.     except smtplib.SMTPException:
  28.         print('Error: sending email failed')
  29.  
  30. username = 'billywangnew@gmail.com'
  31. password = ''
  32.  
  33. subj = 'Test email'
  34. body = 'Did this work?'
  35.  
  36. # scrape_registrar()
  37.  
  38. send_email('billywangnew@gmail.com', username, password, ['jerrylinew@gmail.com'], subj, body)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement