Is there a way to unfollow users by a list?
yes it is very easy to do,
just add a new argument to unfollow_users() method, and add a new condition to unfollow() function in unfollow_util.py
then pass user list, to that statement...
Do I have to change the InstaPy source code?
Yes, actually you are adding a new parameter!
Follow these steps
instapy.py file, find def unfollow_users( and add your new parameter UnfollowByListit will be like this
def unfollow_users(self,
amount=10,
onlyInstapyFollowed=False,
onlyInstapyMethod='FIFO',
sleep_delay=600,
onlyNotFollowMe=False,
UnfollowByList=None): #new parameter here
"""Unfollows (default) 10 users from your following list"""
if onlyInstapyFollowed == True: #only generate FollowedPool in onlyInstaPyFollowed method
self.automatedFollowedPool = set_automated_followed_pool(self.username,
self.logger,
self.logfolder)
try:
unfollowNumber = unfollow(self.browser,
self.username,
amount,
self.dont_include,
onlyInstapyFollowed,
onlyInstapyMethod,
self.automatedFollowedPool,
sleep_delay,
onlyNotFollowMe,
self.logger,
self.logfolder,
UnfollowByList) #pass your new parameter to unfollow utility
unfollow() function in unfollow_util.py to have UnfollowByList parameterdef unfollow(browser,
username,
amount,
dont_include,
onlyInstapyFollowed,
onlyInstapyMethod,
automatedFollowedPool,
sleep_delay,
onlyNotFollowMe,
logger,
logfolder,
UnfollowByList): #new parameter here
unfollow() function to do unfollowing by listso, find if onlyInstapyFollowed is True: in unfollow_util.py file and add these lines before it (beware of indentation)
get it here (cos of Github messes with indentation, I pastebinned it)
@lovePizza
_use it like this_...
session.unfollow_users(UnfollowByList=['first_user', 'second_unfllow', 'other user', 'blah_blah'], amount=100, onlyInstapyFollowed=False, onlyInstapyMethod='FIFO', sleep_delay=600, onlyNotFollowMe=False)
it will unfollow every user in the list _you give_ (if you really are following them...)
and it will not care the amount you give it in there
if you don't want to use UnfollowByList method some other time, give it a None value or just remove it from session.unfollow_users()
i haven't tested, if something is not working as expected, please, let me know :-)
Thanks, it works, I only had to set "amount=0" in the "session.unfollow_users" function
Thanks a lot @uluQulu ! Works great.
Remember to change if onlyInstapyFollowed is True: to elif onlyInstapyFollowed is True:
Otherwise it will continue its regular unfollowing routine and unfollow X people from your account. Of course you can just set amount=0 as @lovePizza mentions.
Nice guys,
I didn't touch it to follow style of unfollow_users()
enable what you wanna use, othervise set them to
False
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
Most helpful comment
Do I have to change the InstaPy source code?