Created
October 1, 2019 12:42
-
-
Save MrEdinLaw/06ae3c7cd06f04ad14a0a8b52dc1fe55 to your computer and use it in GitHub Desktop.
Reddit image poster from folder. Credits to u/CivilizedGravy
This file contains hidden or 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 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