When a private account is encountered during unfollow_users , this error message is displayed:
WARNING - --> Cannot Unfollow from InstaPy (number), now unfollowing (private user)
But the private user is still deleted from the FollowedPool.csv . As a result, the user will never be unfollowed by InstaPy even after the follow request is accepted.
Encountering a certain number of Cannot Unfollows seems to also end the program prematurely. I had 24 accounts remaining in my FollowedPool.csv after a run written to unfollow all InstaPy followed users.
are you trying to untick Requested buttons too?
or
don't wanna remove them from username_followedPool.csv until they accepted your request?
@jeremyccheung
@uluQulu untick Requested buttons is what I'd like to do, but your other suggestion would be very useful as well! Are there code modifications to perform both?
Any news on this? I'm having the same problem.
I have shared some lines of code for doing this in our slack channel for some guys,
you will change 2 places:
first, add Requested in XPATH and add Requested to if conditional statement in unfollow() function of unfollow_util.py
basically, you need to modify this onlyfor OnlyIstaPyFollowed=True method
I don't know what are the line numbers in your file, just open unfollow_util.py and navigate to unfollow() function
there find if onlyInstapyFollowed is True: condition and change,
follow_button = browser.find_element_by_xpath(
"//*[contains(text(), 'Follow')]")
if follow_button.text == 'Following':
to
follow_button = browser.find_element_by_xpath(
"//*[contains(text(), 'Follow') or contains(text(), 'Requested')]")
if follow_button.text in ['Following', 'Requested']:
one more place you would also like to modify is unfollow_user() function in same file (it is used in like_by_feed feature while an inappropriate pic is seen, it will unfollow with unfollow_user() function...) change similarly as above,,
_jeremy, I don't think you would like to keep users until they accepted request, instead I offer you to use my unfollow_after argument which enables you to unfollow users only after following them certain amount of time you want (e.g. 2 days as I use...)_
_i dont recommend, cos if you wait for them accept your request, then unfollow, your unfollow list will be bloated and most of them will not accept (as general...) but it is still possible, if you insist, let me know to help you achieve it too!_
@jeremyccheung @arthurecommerce
@uluQulu Was going to take a look at the unfollow_util.py and make a change to the find_element_by_xpath as a possible solution; this is exactly the resolution I was looking for! Thank you so much for sharing
I have also read your code for the unfollow_after function that you created; very solid work!
@uluQulu Update: The fix seems to work, but I realized the program still displays a "cannot unfollow" message for private accounts even after they are unfollowed successfully and does not count them in the final unfollowed number.
Do I need to change my current code for cleanliness?
if person not in dont_include:
browser.get('https://www.instagram.com/' + person)
sleep(2)
follow_button = browser.find_element_by_xpath(
"//*[contains(text(), 'Follow') or contains(text(), 'Requested')]")
if follow_button.text in ['Following', 'Requested']:
unfollowNum += 1
follow_button.click()
update_activity('unfollows')
delete_line_from_file('./logs/' + username +
'_followedPool.csv', person +
",\n", logger)
logger.info(
'--> Ongoing Unfollow From InstaPy {},'
' now unfollowing: {}'
.format(str(unfollowNum), person.encode('utf-8')))
sleep(15)
if hasSlept:
hasSlept = False
continue
else:
delete_line_from_file('./logs/' + username +
'_followedPool.csv',
person + ",\n", logger)
logger.warning(
'--> Cannot Unfollow From InstaPy {}'
', now unfollowing: {}'
.format(str(unfollowNum), person.encode('utf-8')))
sleep(2)
Do you see Follow Back button after unfollowing somebody who follows you?
@jeremyccheung
maybe you have already unfollowed them, but it is still in your list, so that it cannot unfollow them again,.....
@uluQulu I do; would further modifications have to be made for instances where the text says Follow Back after unfollowing to contribute to the counter?
@uluQulu ran the program this morning and had one private account remaining that wasn鈥檛 unfollowed. Ran it again and the remaining private account was successfully unfollowed without a warning message displayed.
Going to keep testing to determine why not all accounts in FollowedPool.csv are unfollowed in one run and why the warning still occurs. My unfollow action amount is always set higher than my follow action amount
I guess so, Follow Back is a new button appeared for some accaunts recently, and should be added to some places...
@uluQulu Just re-read the unfollow_util.py code and it doesn't seem like the Follow Back button would affect any part of the unfollow process. Assuming one's goal behind following a user through InstaPy is to convert them into an account follower, I'm not sure if it would be necessary to add the Follow Back button to the program's follow functions.
Right, after the latest commits there is 2 more conditional statements, and I guess you have not pulled them, so you don't need to add Follow Back until pulls those commits
at your situation, i think you have already unfollowed those people, but they are still in your list, so it cannot unfollow them again cos button is already Follow
@jeremyccheung
@uluQulu Just pulled the latest commits; it looks like Follow Back was added in a few places in unfollow_util.py already
I've also determined the key cause of the program not unfollowing all accounts, but will open a separate issue for that right now as it is not related to account privacy settings. Thank you!
@jeremyccheung does this mean that all we have to do is a git pull and all should be resolved?
@Namaslayer Can you clarify which issues you're referring to when you say "all should be solved"? If you mean unfollowing private accounts then no, but following @uluQulu 's steps in the post above will fix it!