I was trying to use comment_user and comment_users functions to comment of user's follower's media.
below is the code
import sys
import os
import time
import random
from tqdm import tqdm
import argparse
sys.path.append(os.path.join(sys.path[0], '../'))
from instabot import Bot
parser = argparse.ArgumentParser(add_help=True)
parser.add_argument('-u', type=str, help="username")
parser.add_argument('-p', type=str, help="password")
parser.add_argument('-proxy', type=str, help="proxy")
parser.add_argument('users', type=str, nargs='+', help='users')
args = parser.parse_args()
bot = Bot(comments_file='comments.txt')
bot.login(username=args.u, password=args.p,
proxy=args.proxy)
for username in args.users:
follower_ids = bot.get_user_followers(username, 100)
bot.comment_users(follower_ids, ncomments=1)`
And this gives the below error
Traceback (most recent call last):
File "comment_user_followers.py", line 32, in <module>
bot.comment_users(follower_ids, ncomments=1)
File "C:\Users\miranthaj\AppData\Local\Programs\Python\Python35\lib\site-packages\instabot\bot\bot.py", line 449, in comment_users
return comment_users(self, user_ids, ncomments)
File "C:\Users\miranthaj\AppData\Local\Programs\Python\Python35\lib\site-packages\instabot\bot\bot_comment.py", line 71, in comment_users
self.comment_user(user_id, amount=ncomments)
File "C:\Users\miranthaj\AppData\Local\Programs\Python\Python35\lib\site-packages\instabot\bot\bot.py", line 446, in comment_user
return comment_user(self, user_id, amount)
File "C:\Users\miranthaj\AppData\Local\Programs\Python\Python35\lib\site-packages\instabot\bot\bot_comment.py", line 58, in comment_user
medias = self.get_user_medias(user_id, is_comment=True)
File "C:\Users\miranthaj\AppData\Local\Programs\Python\Python35\lib\site-packages\instabot\bot\bot.py", line 234, in get_user_medias
return get_user_medias(self, user_id, filtration, is_comment)
File "C:\Users\miranthaj\AppData\Local\Programs\Python\Python35\lib\site-packages\instabot\bot\bot_get.py", line 52, in get_user_medias
return self.filter_medias(self.LastJson["items"], filtration, is_comment=is_comment)
File "C:\Users\miranthaj\AppData\Local\Programs\Python\Python35\lib\site-packages\instabot\bot\bot.py", line 477, in filter_medias
return filter_medias(self, media_items, filtration, quiet, is_comment)
File "C:\Users\miranthaj\AppData\Local\Programs\Python\Python35\lib\site-packages\instabot\bot\bot_filter.py", line 36, in filter_medias
media_items = _filter_medias_not_commented(self, media_items)
File "C:\Users\miranthaj\AppData\Local\Programs\Python\Python35\lib\site-packages\instabot\bot\bot_filter.py", line 55, in _filter_medias_not_commented
my_comments = [comment for comment in media['comments'] if comment['user_id'] == self.user_id]
KeyError: 'comments'`
I was trying to use comment_user and comment_users functions to comment of user's follower's media.
below is the code
And this gives the below error
Please let me what I'm doing wrong here.
Thank you!