Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. import praw
  2. import re
  3. from praw.models import Comment
  4. from newspaper import Article
  5. import time
  6.  
  7. uname = 'username'
  8. reddit = praw.Reddit(client_id='clientid',
  9. client_secret='clientsecret',
  10. password='password',
  11. user_agent='Script by me',
  12. username=uname)
  13.  
  14. while True:
  15. unread_messages = []
  16. for item in reddit.inbox.unread(limit=None):
  17. if isinstance(item, Comment):
  18. submission = item.submission
  19. comment_body = item.body
  20. print(comment_body)
  21. if not submission.is_self and comment_body == "/u/" + uname:
  22. url = submission.url
  23. article = Article(url)
  24. article.download()
  25. article.parse()
  26. reddit.redditor(item.author.name).message(article.title, article.text)
  27. unread_messages.append(item)
  28. reddit.inbox.mark_read(unread_messages)
  29. time.sleep(300)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement