Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Way to compare two subreddit users
import praw
import csv
reddit = praw.Reddit(client_id='YOUR-CLIENT-ID',
client_secret='YOUR-SECRET-API-KEY-HERE',
user_agent='blablabl kjoenth whatever')
userListOne = []
userListTwo = []
commonUsers = []
theLimiter = 100000
theSubredditNameOne = "The_Donald"
theSubredditNameTwo = "nofap"
###Section one
print "******Reading in r/%s usernames from 'hot' topics!" % (theSubredditNameOne)
for submission in reddit.subreddit(theSubredditNameOne).hot(limit=theLimiter):
#print(submission.title)
theAuthor = submission.author
if theAuthor not in userListOne:
#print theAuthor
userListOne.append(theAuthor)
print "******Reading in r/%s usernames from comments!" % (theSubredditNameOne)
for aComment in reddit.subreddit(theSubredditNameOne).comments(limit=theLimiter):
theCommenter = aComment.author
if theCommenter not in userListOne:
#print theCommenter
userListOne.append(theCommenter)
###Section one
print "******Reading in r/%s usernames from 'hot' topics!" % (theSubredditNameTwo)
for submission in reddit.subreddit(theSubredditNameTwo).hot(limit=theLimiter):
#print(submission.title)
theAuthor = submission.author
if theAuthor not in userListTwo:
#print theAuthor
userListTwo.append(theAuthor)
print "******Reading in r/%s usernames from comments!" % (theSubredditNameTwo)
for aComment in reddit.subreddit(theSubredditNameTwo).comments(limit=theLimiter):
theCommenter = aComment.author
if theCommenter not in userListTwo:
#print theCommenter
userListTwo.append(theCommenter)
print ""
print "Search limited to %i" % (theLimiter)
print "%i unique names in r/%s list" % (len(userListOne), theSubredditNameOne)
print "%i unique names in r/%s list" % (len(userListTwo), theSubredditNameTwo)
print "\n***Comparision of lists starting...."
for aName in userListOne:
if aName in userListTwo:
commonUsers.append(aName)
#print aName
print "%i common users" % (len(commonUsers))
print "\nDone."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.