Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import praw
- user_agent = ("/r/trees high average checker")
- r = praw.Reddit(user_agent=user_agent)
- trees = r.get_subreddit('trees')
- submissions = trees.get_hot(limit=1)
- highs = []
- def check_text(text):
- indexes = []
- i = 0
- for character in text:
- i+=1
- if character == '[' or character == '{':
- indexes.append(i)
- for index in indexes:
- try:
- high = int(text[index])
- highs.append(high)
- except: pass
- def check_submissions(amount=10):
- submissions = trees.get_hot(limit=amount)
- for submission in submissions:
- check_text(submission.title)
- for comment in submission.comments:
- if not isinstance(comment, praw.objects.MoreComments): check_text(comment.body)
- def check_avg():
- total = 0
- for high in highs:
- total += high
- return total/len(highs)
- check_submissions(amount=100)
- print check_avg()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement