Last active
July 18, 2019 04:00
-
-
Save bchauSW/49823e399e37c002cc779d9ed059565e to your computer and use it in GitHub Desktop.
This script finds a person who posts to two specified subreddits.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import praw | |
reddit = praw.Reddit(client_id='clientid', | |
client_secret='clientsecret', | |
password='password', | |
user_agent='Script by me', | |
username='username') | |
checked_users = [] | |
with open('users.txt', 'w+') as f: | |
for submission in reddit.subreddit('askreddit').top(limit=100): | |
author = submission.author | |
if not author is None and author.name not in checked_users: | |
checked_users.append(author.name) | |
redditor_submissions = author.submissions.hot(limit=100) | |
for r_submission in redditor_submissions: | |
if r_submission.subreddit == 'strangerthings' and not r_submission.is_self: | |
f.write(author.name + '\n') | |
f.write('First Link: ' + submission.subreddit.name + '\n') | |
f.write('Second Link: ' + r_submission.subreddit.name + '\n\n') | |
print(author.name) | |
break | |
I was able to get it to work as expected. Thank you.
What are the do the values of "First Link & Second Link" represent?
-eDgAR-
First Link: t5_2qh1i
Second Link: t5_3adlm
The links seem to point to the link to the post. By using "submission.subreddit.name", it will display the subreddit of the submission.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You will also need to register your own app with Reddit via this link, and replace the data at the top of the script with your own credentials.