Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import praw
- import wordcloud
- import os
- import re
- r = praw.Reddit("/u/Bspammer")
- def subredditWordCloud(subreddit):
- sub = r.get_subreddit(subreddit)
- comments = sub.get_comments(limit=None)
- rawtext = ""
- for c in comments:
- rawtext += c.body + " :::: "
- rawtext = re.sub(r'[^a-zA-Z0-9\': ]', '', rawtext)
- f = open("wordclouds/" + subreddit + "Comments.txt", "w")
- f.write(rawtext)
- f.close()
- wc = wordcloud.WordCloud(max_words=1000, width=1920, height=1080,
- stopwords=wordcloud.STOPWORDS.copy(), margin=10, random_state=1).generate(rawtext.lower())
- wc.to_file("wordclouds/" + subreddit + "Wordcloud.png")
- subredditWordCloud("rocketleague")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement