ohld / igbot

🐙 Free scripts, bots and Python API wrapper. Get free followers with our auto like, auto follow and other scripts!
https://hikerapi.com/p/N2P6iqiM
Apache License 2.0
4.72k stars 1.47k forks source link

BUG report follow_users_from_file.py results in error #496

Closed dirkrmeij closed 6 years ago

dirkrmeij commented 6 years ago

For a bug report, you must include the Python version used, code that will reproduce the error, and the error log/traceback.

Paste the output of python -V here: Python 2.7.10 (default, Oct 6 2017, 22:29:07)

Code:

# python follow_users_from_file.py followusers.txt

import argparse
import os
import sys

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('filepath', type=str, help='filepath')
args = parser.parse_args()

bot = Bot(filter_users=False)
users_to_follow = bot.read_list_from_file(args.filepath)
if not users_to_follow:
    exit()
else:
    print("Found %d users in file." % len(users_to_follow))

bot.login(username=args.u, password=args.p,
          proxy=args.proxy)

bot.follow_users(users_to_follow)

Error/Debug Log:

Writing user_id to file : followed.txt ... 
Processed users:   2%|▎                       | 5/331 [01:59<2:09:57, 23.92s/it]Traceback (most recent call last):
  File "follow_users_from_file.py", line 33, in <module>
    bot.follow_users(users_to_follow)
  File "/Library/Python/2.7/site-packages/instabot/bot/bot.py", line 388, in follow_users
    return follow_users(self, user_ids)
  File "/Library/Python/2.7/site-packages/instabot/bot/bot_follow.py", line 46, in follow_users
    if not self.follow(user_id):
  File "/Library/Python/2.7/site-packages/instabot/bot/bot.py", line 385, in follow
    return follow(self, user_id)
  File "/Library/Python/2.7/site-packages/instabot/bot/bot_follow.py", line 8, in follow
    user_id = self.convert_to_user_id(user_id)
  File "/Library/Python/2.7/site-packages/instabot/bot/bot.py", line 324, in convert_to_user_id
    return convert_to_user_id(self, usernames)
  File "/Library/Python/2.7/site-packages/instabot/bot/bot_get.py", line 226, in convert_to_user_id
    if smth[0] == "@":  # cut first @
IndexError: string index out of range
2018-04-17 10:33:37,246 - INFO - Bot stopped. Worked: 0:18:43.552323
2018-04-17 10:33:37,246 - INFO - Total followed: 23
2018-04-17 10:33:37,246 - INFO - Total requests: 51

---

Describe your issue

Looks like there is a issue in the example file if I am not mistaken.

basnijholt commented 6 years ago

Thanks for your report!

I fixed this error in https://github.com/instagrambot/instabot/pull/508

The problem is actually that you have an empty line with a space in followed.txt. When https://github.com/instagrambot/instabot/pull/508 is merged, this shouldn't be a problem anymore.