Skip to content

Instantly share code, notes, and snippets.

@seanth
Created October 29, 2018 15:27
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 seanth/ab79b752a14a20a9630215ce7fcc0ca5 to your computer and use it in GitHub Desktop.
Save seanth/ab79b752a14a20a9630215ce7fcc0ca5 to your computer and use it in GitHub Desktop.
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