-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstapraw.py
33 lines (27 loc) · 987 Bytes
/
instapraw.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import praw
from instabot import Bot
import random, requests
import config
bot = Bot()
bot.login(username = config.username, password = config.password)
reddit = praw.Reddit(client_id = config.client_id,
client_secret = config.client_secret,
user_agent = config.user_agent)
meme = reddit.subreddit('memes').hot()
meme_post = random.randint(1, 50)
for i in range(0, meme_post):
submission = next(x for x in meme if x.stickied == False)
extension = submission.url[len(submission.url) - 3 :].lower()
if 'gif' not in extension:
pass
else:
continue
r = requests.get(submission.url)
with open('post.jpeg', 'wb') as f:
f.write(r.content)
print("Image Downloaded!")
print()
caption = submission.title + '\n.\n.\n.\nPosted by: u/ ' + str(submission.author) + '\n\n #memes #dankmemes #reddit #funny #robot #bot'
bot.upload_photo('post.jpeg', caption = caption)
bot.logout()
input('Press any key to continue...')