Advertisement
Guest User

should_of_bot

a guest
May 1st, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. import praw
  2.  
  3. username = 'placeholder'
  4. password = 'placeholderpw'
  5. subnames = ['the_donald','sandersforpresident','blackpeopletwitter']
  6. bad_words = ['should of','should\'of','shouldof','shouldov']
  7. good_words = ['should have','should\'ve','shouldve']
  8. cnt_of = 0
  9. cnt_have = 0
  10.  
  11. r = praw.Reddit(user_agent='/u/'+username+' making stupid statistics instead of studying quantum physics')
  12. r.login(username,password,disable_warning=True)
  13.  
  14. for sub in subnames:
  15.     for submission in r.get_subreddit(sub).get_top_from_all(limit=10):
  16.         submission.replace_more_comments(limit=None, threshold=0)
  17.         flat_comments = praw.helpers.flatten_tree(submission.comments)
  18.         for comment in flat_comments:
  19.             if any(bad_word in comment.body for bad_word in bad_words):
  20.                 cnt_of += 1
  21.             elif any(good_word in comment.body for good_word in good_words):
  22.                 cnt_have += 1
  23.                
  24.     print sub + ' should of:' + str(cnt_of)
  25.     cnt_of = 0
  26.     print sub + ' should have:' + str(cnt_have)
  27.     cnt_have = 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement