-
-
Save bchauSW/49823e399e37c002cc779d9ed059565e to your computer and use it in GitHub Desktop.
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 | |
Could you provide more information on how to use this script? I have replaced both 'subreddit' & 'another subreddit' with subs i have posted in recently and cannot get the script to return any results.
I missed the 'name' field when writing the subreddit name to the file, which may have caused the issue.
Trying the example that I have now, it should return /u/-eDgAR- as one of the results.
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.
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.
Could you provide more information on how to use this script? I have replaced both 'subreddit' & 'another subreddit' with subs i have posted in recently and cannot get the script to return any results.