InstaPy / InstaPy

📷 Instagram Bot - Tool for automated Instagram interactions
GNU General Public License v3.0
16.73k stars 3.77k forks source link

Unable to get user list on headless instance #2029

Closed therealahall closed 5 years ago

therealahall commented 6 years ago

Expected Behavior

Script performs as it does on Mac OS

Current Behavior

Both following and unfollowing appear to not be working in a headless environment.

INFO [2018-05-12 23:19:11] [my_user] Session started - 2018-05-12 23:19:11 INFO [2018-05-12 23:19:40] [my_user] Logged in successfully! ERROR [2018-05-12 23:20:06] [my_user] Could not determine if [their_user] has followers INFO [2018-05-12 23:20:06] [my_user] --> Total people followed : 0 INFO [2018-05-12 23:20:06] [my_user] Starting to follow likers.. INFO [2018-05-12 23:20:09] [my_user] Finished following likers!

Note that the liking of photos by tag is working in this configuration

Possible Solution (optional)

Server setup

Ubuntu 16.04.4 LTS Python 2.7.12 Followed the instructions here: https://github.com/timgrossmann/InstaPy/blob/master/docs/How_To_DO_Ubuntu_on_Digital_Ocean.md

Same configuration works on MacOS by turning headless_browser=False and removing the nogui line

InstaPy configuration

session = InstaPy(username=insta_username, password=insta_password, headless_browser=True, nogui=True, multi_logs=True)

def my_shuffle(array): random.shuffle(array) return array

try: session.login()

# set up all the settings
session.set_relationship_bounds(enabled=True,
                 potency_ratio=None,
                  delimit_by_numbers=True,
                   max_followers=2500,
                    max_following=2500,
                     min_followers=50,
                      min_following=50)

# settings
session.set_do_follow(enabled=True, percentage=0, times=1)

users = [user_array]
tags = [tag_array]

# follow

print "Shuffling users\r\n"
followUsers=my_shuffle(users)
for followKey,followUser in enumerate(followUsers):
    randomAmount = random.randint(1,5)
    randomGrabAmount = random.randint(1,5)
    print "Working on #" + str(followKey) + " user: " + followUser + ". Following " + str(randomAmount) + " users and grabbing " + str(randomGrabAmount) + " photos.\r\n"
    session.follow_user_followers([followUser], amount=randomAmount, randomize=True, sleep_delay=60)
    session.follow_likers([followUser], photos_grab_amount = randomGrabAmount, follow_likers_per_photo = 1, randomize=True)

# like

print "Shuffling tags\r\n"
likeByTags=my_shuffle(tags)
for likeByTagKey,likeByTagTag in enumerate(likeByTags):
    randomLikeAmount = random.randint(1,6)
    print "Working on liking #" + str(likeByTagKey) + " tag: " + str(randomLikeAmount) + " random photos in tag " + likeByTagTag + "\r\n"
    session.like_by_tags([likeByTagTag], amount=randomLikeAmount)

#unfollow

randomUnfollowAmount = random.randint(100,301)
print "Unfollowing " + str(randomUnfollowAmount) + " total users\r\n"
session.unfollow_users(amount=randomUnfollowAmount, onlyInstapyFollowed = True, onlyInstapyMethod = 'FIFO', sleep_delay=600, unfollow_after=120*60*60 )

# like

randomSelfLikeAmount = random.randint(1,21)
print "Liking " + str(randomSelfLikeAmount) + " photos from our feed\r\n"
session.like_by_feed(amount=randomSelfLikeAmount, randomize=False, unfollow=False, interact=False)
sionking commented 6 years ago

I don't recommend headless

therealahall commented 6 years ago

Any reason why not?

sionking commented 6 years ago

it is detectable,

therealahall commented 6 years ago

How is it any more detectable than running it on my local machine that pops up the GUI version of chrome?

sionking commented 6 years ago

https://antoinevastel.com/bot%20detection/2018/01/17/detect-chrome-headless-v2.html

therealahall commented 6 years ago

Cool, I’ll see if the same is available for Firefox. I have more experience running headless Firefox than I do chrome. I just went that route because it was officially listed in the documentation for the repo

claygorman commented 6 years ago

I have this same issue

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this problem still occurs, please open a new issue