Instapy: Set_unfollow_active_users not working

Created on 4 Nov 2017  路  5Comments  路  Source: timgrossmann/InstaPy

Hi,

First of all thanks for all your work!

I would like to unfollow 5 accounts that have been followed by Instapy, starting from the oldest followed account to the newest, and only unfollow inactive accounts (that didn't like one of my 2 last pictures for example).

To do so, I'm using this code:

InstaPy(username=insta_username, password=insta_password)\
  .login()\
  .set_unfollow_active_users(enabled=True, posts=2)\
  .unfollow_users(amount=5, onlyInstapyFollowed = True, onlyInstapyMethod = 'FIFO', sleep_delay=10)\
  .end()

But I get this error message:

Logged in successfully!
Traceback (most recent call last):
  File "unfollow.py", line 8, in <module>
    .set_unfollow_active_users(enabled=True, posts=2)\
AttributeError: 'NoneType' object has no attribute 'unfollow_users'

Interchange the order of set_unfollow_active_users and unfollow_users does not solve anything:

InstaPy(username=insta_username, password=insta_password)\
  .login()\
  .unfollow_users(amount=5, onlyInstapyFollowed = True, onlyInstapyMethod = 'FIFO', sleep_delay=10)\
  .set_unfollow_active_users(enabled=True, posts=5)\
  .end()

Error message:

--> Cannot Unfollow From InstaPy 0, now unfollowing: b'vicky.johansson' #Because already unfollowed by hand
--> Cannot Unfollow From InstaPy 0, now unfollowing: b'_angel_insta_' #Because already unfollowed by hand
--> Ongoing Unfollow From InstaPy 1, now unfollowing: b'carlosjthode'
--> Total unfollowNum reached it's amount given  1
--> Total people unfollowed : 1 
Traceback (most recent call last):
  File "unfollow.py", line 9, in <module>
    .set_unfollow_active_users(enabled=True, posts=2)\
AttributeError: 'NoneType' object has no attribute 'end'

When doing the ".set_unfollow_active_users(...)", it seems unable to load all the accounts that liked my last pictures (around 300), directly goes to the previous picture, still unable to load all the accounts that liked the picture and then crashes...

Thanks so much in advance for your help!
Have a great day!
Thomas

Ps: Lastly, what do exactly mean FIFO vs LIFO?
Pss: I would also be interested in being able to unfollow accounts that didn't follow back in a given amount of time. Does this function already exist?

help wanted

All 5 comments

hey @thomascello , thank you for you detailed informations. More people are having issues with this function, I'll take a look on it. FIFO (first in, first out), LIFO...

*I think your InstaPy is outdated

Hey @converge,

Thanks for your very quick answer! I look forward to know more about this issue.

*Indeed, it was outdated. However I just git pulled but still the same issues....
*FIFO: so it means that the oldest followed account will be the first the be unfollowed right?

@thomascello, just made a PR #867 , can you test it ?

about FIFO, you're right, when you follow users they go to a list, when unfollowing this list will use FIFO to unfollow then in order.

I just did it!

I ran:

InstaPy(username=insta_username, password=insta_password)\
  .login()\
  .set_dont_unfollow_active_users(enabled=True, posts=2)\
  .unfollow_users(amount=1, onlyInstapyFollowed = True, onlyInstapyMethod = 'FIFO', sleep_delay=10)\
  .end()

I got this error message:

Logged in successfully!
Traceback (most recent call last):
  File "unfollow.py", line 8, in <module>
    .set_dont_unfollow_active_users(enabled=True, posts=2)\
  File "/home/tm/Desktop/Projets Info/Instagram/InstaPy/instapy/instapy.py", line 1394, in set_dont_unfollow_active_users
    active_users = get_active_users(self.browser, self.username, posts)
  File "/home/tm/Desktop/Projets Info/Instagram/InstaPy/instapy/util.py", line 107, in get_active_users
    '//header/div[2]/ul/li[1]/span/span').text)
  File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 365, in find_element_by_xpath
    return self.find_element(by=By.XPATH, value=xpath)
  File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 843, in find_element
    'value': value})['value']
  File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 308, in execute
    self.error_handler.check_response(response)
  File "/usr/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//header/div[2]/ul/li[1]/span/span"}
  (Session info: chrome=62.0.3202.75)
  (Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.13.9-1-ARCH x86_64)

Thanks for your help!

867 fixed it

Was this page helpful?
0 / 5 - 0 ratings

Related issues

deronsizemore picture deronsizemore  路  3Comments

rahulkapoor90 picture rahulkapoor90  路  3Comments

46960 picture 46960  路  3Comments

drcyber975 picture drcyber975  路  3Comments

thisishotdog picture thisishotdog  路  3Comments