InstaPy / InstaPy

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

Does not unfollow at all #3077

Closed nazariyv closed 5 years ago

nazariyv commented 6 years ago

Expected Behavior

Unfollows users

Current Behavior

Does not talk about shadowbans, just cannot retrieve any following to unfollow:

After getting a list of my followers

INFO [2018-10-03 18:43:31] [----]  Zz :[ time to take a good nap  ~sleeping 36.0 seconds
INFO [2018-10-03 18:44:03] [----]  Yawn :] let's go!

INFO [2018-10-03 18:44:03] [----]  Found xx loyal followers!  ~will not unfollow them
INFO [2018-10-03 18:44:03] [----]  Total 0 users available to unfollow  ~didn't pass `unfollow_after`: 0

INFO [2018-10-03 18:44:03] [----]  There are no any users available to unfollow
INFO [2018-10-03 18:44:03] [----]  --> Total people unfollowed : 0

INFO [2018-10-03 18:44:03] [----]  Sessional Live Report:
        |> LIKED 0 images  |  ALREADY LIKED: 0
        |> COMMENTED on 0 images
        |> FOLLOWED 0 users  |  ALREADY FOLLOWED: 0
        |> UNFOLLOWED 0 users
        |> INAPPROPRIATE images: 0
        |> NOT VALID users: 0
currently FOLLOWING xxx users & has got xxx FOLLOWERS

OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
INFO [2018-10-03 18:44:03] [----]  Session ended!
ooooooooooooooooooooooooooooooooooooooooooooooooooooo

INFO [2018-10-03 18:44:03] [----]  Sessional Live Report:
        |> LIKED 0 images  |  ALREADY LIKED: 0
        |> COMMENTED on 0 images
        |> FOLLOWED 0 users  |  ALREADY FOLLOWED: 0
        |> UNFOLLOWED 0 users
        |> INAPPROPRIATE images: 0
        |> NOT VALID users: 0
currently FOLLOWING xxx users & has got xxx FOLLOWERS

OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
INFO [2018-10-03 18:44:03] [----]  Session ended!
ooooooooooooooooooooooooooooooooooooooooooooooooooooo

Possible Solution (optional)

InstaPy configuration

unfollow_amount_number = 300

session.unfollow_users(amount=unfollow_amount_number, InstapyFollowed=(True, "nonfollowers"),
                           style="FIFO",
                           unfollow_after=8 * 60 * 60,
                           sleep_delay=400)

literally just that

didamos99 commented 6 years ago

What I can see here is that it should unfollow them after 8 hours so if you start this config after 8 hours it should unfollow them again.

didamos99 commented 6 years ago

13:00 script started followed 100 people for example unfollowed 0 00:00 script started again followed 100 people but unfollowed arround 50-150 people that are the followers you we're following at 13:00 I hope this makes it clear for you :)

nazariyv commented 6 years ago

Actually, not the case. Still same problem.

nazariyv commented 6 years ago

Can at least someone say where to look? The problem is that it cannot find the users to unfollow. It successfully grabs followers, but it always grabs 0 following, or rather 0 to unfollow....

TheSnakeRekt commented 6 years ago

Same problem here does not unfollow at all

elypsis commented 6 years ago

same problem here

jp-sjc commented 6 years ago

Same problem here.

nazariyv commented 6 years ago

Now at least I'm getting some sort of a traceback, I think this is related to the issue:

Traceback (most recent call last):
  File "quickstart_en.py", line 94, in <module>
    interact=True)
  File "/home/nazariy/git/InstaPy/instapy/instapy.py", line 2487, in follow_user_followers
    self.logfolder)
  File "/home/nazariy/git/InstaPy/instapy/unfollow_util.py", line 906, in get_given_user_followers
    channel, jumps, logger, logfolder)
  File "/home/nazariy/git/InstaPy/instapy/unfollow_util.py", line 713, in get_users_through_dialog
    person_list = dialog_username_extractor(buttons)
  File "/home/nazariy/git/InstaPy/instapy/unfollow_util.py", line 736, in dialog_username_extractor
    if person and hasattr(person, 'text') and person.text:
  File "/home/nazariy/anaconda/envs/insta_fame/lib/python3.7/site-packages/selenium/webdriver/remote/webelement.py", line 76, in text
    return self._execute(Command.GET_ELEMENT_TEXT)['value']
  File "/home/nazariy/anaconda/envs/insta_fame/lib/python3.7/site-packages/selenium/webdriver/remote/webelement.py", line 628, in _execute
    return self._parent.execute(command, params)
  File "/home/nazariy/anaconda/envs/insta_fame/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 320, in execute
    self.error_handler.check_response(response)
  File "/home/nazariy/anaconda/envs/insta_fame/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
  (Session info: chrome=69.0.3497.100)
  (Driver info: chromedriver=2.41.578700 (2f1ed5f9343c13f73144538f15c00b370eda6706),platform=Linux 4.15.0-36-generic x86_64)

Here is the snapshot of my packages:

certifi==2018.8.24
chardet==3.0.4
clarifai==2.3.1
configparser==3.5.0
EasyProcess==0.2.3
emoji==0.5.0
future==0.16.0
gitdb2==2.0.4
GitPython==2.1.11
grpcio==1.15.0
idna==2.7
instagram-py==0.0.1
jsonschema==2.6.0
numpy==1.15.1
Pillow==5.2.0
plyer==1.3.0
protobuf==3.6.1
PyVirtualDisplay==0.2.1
requests==2.19.1
selenium==3.14.0
six==1.11.0
smmap2==2.0.4
urllib3==1.23
nazariyv commented 6 years ago

Updating to latest chromedriver does not fix the issue.

nazariyv commented 6 years ago

@uluQulu @timgrossmann can you have a look, please?

nazariyv commented 6 years ago

This fix: https://github.com/timgrossmann/InstaPy/pull/3159/commits/d90df65384777aa8d8cd9dde7b35f49cbfa5104c

doesn't help either. It still gives this well-versed error: "There are no any users available to unfollow"...

nazariyv commented 6 years ago

The problem starts here. The automatedFollowPool is:{'all':{},'eligible':{}} and thus unfollowList is an empty list:

        elif InstapyFollowed == True:
            logger.info("Unfollowing the users followed by InstaPy\n")
            unfollow_list = list(automatedFollowedPool["eligible"].keys())

But I can see that it gets the allfollowing number correctly.

nazariyv commented 6 years ago

Ok, I have identified the problem in my case. When set_automated_follow_pool is entered into, try doesn't execute and BaseException is caught. In my case it is:

Error occurred while generating a user list from the followed pool!
    b'line contains NULL byte'

After this happens, we are left with automatedFollowPool that has empty dict for all and eligible. I will have a look at how to fix this error now.

nazariyv commented 6 years ago

If your problem is the same as mine, i.e. you have a NULL byte in your .csv (I really have no idea what is causing this). Then here is how you fix it.

  1. Go to instapy folder.
  2. add this line of code in unfollow_util.py at the very top (where the imports are): import codecs
  3. Add this method above the set_automated_followed_pool method:
    def fix_nulls(s):
    for line in s:
        yield line.replace('\0', '')
  4. Sub the following line in set_automated_followed_pool method: reader = csv.reader(followedPoolFile) with this line: reader = csv.reader(fix_nulls(codecs.open(followedPoolFile.name, 'r+', 'utf-8')))

And you are golden. Unfollowing should work now.

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

jeffdt52 commented 5 years ago

@nazariyv I have this problem periodically when I don't practice good unfollow hygiene (still following people after +4 days when i neglect to run the script)

Cannot identify the null line you talk about in the csv. I figure you mean file user_followedPool.csv. Do you know of manually fixing the null element? Right now this entire file is blank for me, is that what you mean? I wonder if there is a hidden capacity of this csv?

ishandutta2007 commented 5 years ago

I realised this lot later. I don't know since when I am shadowbanned. I have stopped instapy after using for 3 months. None of my posts show on discovery or on hashtags page. I would request all instapy users to check if they are shadow banned or not.