28
loading...
This website collects cookies to deliver better user experience
Friends, When you are a beginner you just google things, mix code from different repositories, add your own code and make it work.
pip install instabot
from instabot import Bot
bot=Bot()
bot.login(username="thiru.jpg",password="followMeOnInstagram")
bot.upload_photo('hey.png',caption=("Test Upload "))
reddit = praw.Reddit(client_id='',
client_secret='',
username='',
password='',
user_agent='')
red='dankmemes'
subreddit = reddit.subreddit(red)
newMemes = subreddit.hot(limit=3)
for submission in new_memes:
if submission.is_self == True:
print("Post was text, skipping to next post.")
continue
else:
pass
url = submission.url
time.sleep(waitTime)
if isImageLink(url) and not already_uploaded(id):
try:
img=requests.get(submission.url)
filename=str(counter)+'.'+IsImageLink(submission.url)
filename=os.path.join('images', filename)
imagefile=open(filename, 'wb')
imagefile.write(img.content)
imagefile.close()
post_ids.append(submission.id) # A list of all submission ids
log_insta(post_ids)
photoAlbum.append({'File':filename, 'Title':submission.title})
#dictionary of all photos
counter+=1
except Exception as e:
print(e)
def log_insta(post_ids):
for post_id in post_ids:
with open(POSTED_CACHE, 'a') as out_file:
out_file.write(str(post_id) + '\n')
elif str(submission.url).lower().startswith('https://imgur.com') or str(submission.url).lower().startswith('http://imgur.com') and counter<max_images:
try:
html_page = urllib.request.urlopen(submission.url)
soup = BeautifulSoup(html_page, 'lxml')
images = []
for img in soup.findAll('img'):
images.append('https:'+img.get('src'))
img=requests.get(images[0])
filename=str(counter)+'.'+images[0][-3:]
authors = ''.join(str(e + ', ') for e in authors)
captionTags='#binod #memes #dank'
for photo in photoAlbum:
img=photo['File']
captionText=photo['Title']
bot.upload_photo(img,caption=(captionText + '\n' +'Reddit Authors:'+authors+'\n' captionTags))
for filename in glob(filePath + '/*'):
os.remove(filename)
python-3.7.3
web: python3 bot.py
worker: python3 bot.py
imageio==2.4.1
praw
requests
urllib3
keyboard
pillow
beautifulsoup4
instabot
heroku ps:scale web=1 worker=1
How many Posts should you upload at a time?
How many hours once should you upload?