Skip to content

Instantly share code, notes, and snippets.

@MrEdinLaw
Created October 1, 2019 12:42
Show Gist options
  • Save MrEdinLaw/06ae3c7cd06f04ad14a0a8b52dc1fe55 to your computer and use it in GitHub Desktop.
Save MrEdinLaw/06ae3c7cd06f04ad14a0a8b52dc1fe55 to your computer and use it in GitHub Desktop.
Reddit image poster from folder. Credits to u/CivilizedGravy
import os
import os.path
import praw
# bot login credentials
username = ''
password = ''
# Your app details
user_agent = 'bot'
client_id = ''
client_secret = ''
subreddit_name = 'test'
directory = "photos"
reddit = praw.Reddit(
client_id=client_id,
client_secret=client_secret,
user_agent=user_agent, username=username,
password=password)
subreddit = reddit.subreddit(subreddit_name)
for filename in os.listdir(directory):
print(os.path.join(directory, filename))
try:
subreddit.submit_image(filename,os.path.join(directory,filename))
print()
except:
continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment