Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import smtplib
- import html5lib, lxml, lxml.cssselect
- import requests
- def scrape_registrar():
- url = 'http://www.registrar.ucla.edu/schedule/detselect.aspx?termsel=16S&subareasel=STATS&idxcrs=0100A+++'
- r = requests.get(url)
- raw_html = r.text
- page = html5lib.parse(raw_html, )
- def send_email(from_user, gmail_user, gmail_pass, to_user, subject, text):
- # from user is single string, to_user is a list of strings
- message = 'Subject: %s\n\n%s' % (subject, text)
- try:
- server = smtplib.SMTP('smtp.gmail.com',587)
- server.ehlo()
- server.starttls()
- server.ehlo()
- server.login(gmail_user, gmail_pass)
- server.sendmail(from_user, to_user, message)
- print('Email sent successfully')
- server.quit()
- except smtplib.SMTPException:
- print('Error: sending email failed')
- username = 'billywangnew@gmail.com'
- password = ''
- subj = 'Test email'
- body = 'Did this work?'
- # scrape_registrar()
- send_email('billywangnew@gmail.com', username, password, ['jerrylinew@gmail.com'], subj, body)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement