Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import praw
- import time
- import itertools
- import smtplib
- from email.mime.text import MIMEText
- SMTP_SERVER = "smtp.mail.yahoo.com"
- SMTP_PORT = 587
- SMTP_USERNAME = "email"
- SMTP_PASSWORD = "pass"
- EMAIL_FROM = "email"
- EMAIL_TO = "3039192150@vtext.com"
- EMAIL_SUBJECT = ""
- msg_to_send = ""
- batch_count = 0
- def redditParse():
- user_agent = ("PyEng Test 0.0.1")
- r = praw.Reddit(user_agent = user_agent)
- tick = 1800
- subreddit = r.get_subreddit("pcmasterrace")
- title = ""
- seen = set()
- for i in itertools.count():
- for submission in subreddit.get_new(limit = 100):
- title = submission.title
- if"giveaway" in title.lower() and (title not in seen):
- #print("\nPost:\t", title)
- #print("Link:\t", submission.url)
- seen.add(title)
- temp_msg_builder(title, submission.url)
- #sleep for a min, then try again
- time.sleep(tick)
- def temp_msg_builder(title, url):
- temp_msg = """
- Post: %s
- Link: %s
- """ % (title, url)
- print("\n\n\n\n\nSENDING: \n", temp_msg)
- send_email(temp_msg)
- def send_email(co_msg):
- try:
- msg = MIMEText(co_msg)
- msg['Subject'] = EMAIL_SUBJECT
- msg['From'] = EMAIL_FROM
- msg['To'] = EMAIL_TO
- debuglevel = True
- mail = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
- mail.set_debuglevel(debuglevel)
- mail.starttls()
- mail.login(SMTP_USERNAME, SMTP_PASSWORD+"77")
- mail.sendmail(EMAIL_FROM, EMAIL_TO, msg.as_string())
- mail.quit()
- print("\n\n\n\nSent!\n\n\n\n")
- except:
- print("Couldn't send")
- redditParse()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement