Skip to content

Instantly share code, notes, and snippets.

@benrules2
Created November 6, 2016 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benrules2/032d3a66343cce680594ef646044bb71 to your computer and use it in GitHub Desktop.
Save benrules2/032d3a66343cce680594ef646044bb71 to your computer and use it in GitHub Desktop.
if __name__ == "__main__":
client_id = 'your_client_id'
client_secret = 'your_client_secret'
reddit_agent = get_reddit_agent('custom name for app', client_id, client_secret)
#list of canadian reddits to search
canada_reddits = ['canada','alberta','britishcolumbia','Manitoba','NewBrunswickCanada', 'newfoundland',
'NovaScotia','nunavut','NWT','ontario','PEI', 'saskatchewan','Yukon']
#empty list where comments will be added
canada_comments = []
for subreddit in canada_reddits:
get_subreddit_comments(reddit_agent, subreddit, canada_comments, count = (1000 / len(canada_reddits)))
canada_sorry, canada_total_words = get_sorry_and_word_count(canada_comments)
#empty list for world comments to be added
world_comments = []
#Using all to represent the global sample, so only 1 subreddit passed in
get_subreddit_comments(reddit_agent, 'all', world_comments, count = 1000)
world_sorry, world_total_words = get_sorry_and_word_count(world_comments)
#print results
print("Canada {} / {}, All {} / {}".format(canada_sorry, canada_total_words, world_sorry, world_total_words))
print("Canada {}% sorry, World {}%".format(float(canada_sorry)/canada_total_words * 100, float(world_sorry)/world_total_words*100))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment