I want to get the number of people I follow from the quickstart.py file.
Then I will do the following logic:
if nb_of_following_people > 1000 :
unfollow()
else :
follow()
Microsoft Windows 10 Pro
Python 3.6.4
This works for me (you can replace "user" by your name for namesake):
Edit: i cleaned the code a bit as i do a different set of actions if the followers to unfollow are greater than 10. You can build your own loop from this. ;)
def my_following_count(browser, username):
browser.get('https://www.instagram.com/' + username)
return browser.execute_script(
"return window._sharedData.""entry_data.ProfilePage[0]."
"graphql.user.edge_follow.count")
user_following_now = my_following_count(session.browser, insta_username)
print("INFO - Following",user_following_now)
if user_following_now <= 1000:
print ("INFO - Following less or equal to 1000")
else:
print ("INFO - Following greater than 1000")
to_unfollow_int = (user_following_now-1000)
if to_unfollow_int <= 10:
print ("INFO -",to_unfollow_int,"to unfollow")
print("INFO - Unfollow",to_unfollow_int, "from Instapy followers - No active followers - Unfollow after 2 days")
session.set_dont_unfollow_active_users(enabled=True, posts=3)
session.unfollow_users(amount=to_unfollow_int, onlyInstapyFollowed = True, onlyInstapyMethod = 'FIFO', sleep_delay=600, unfollow_after=48*60*60)
else:
print ("INFO -",to_unfollow_int,"to unfollow")
print("INFO - Unfollow",to_unfollow_int, "from Instapy followers - No active followers - Unfollow after 2 days")
session.set_dont_unfollow_active_users(enabled=True, posts=3)
session.unfollow_users(amount=to_unfollow_int, onlyInstapyFollowed = True, onlyInstapyMethod = 'FIFO', sleep_delay=600, unfollow_after=48*60*60)
Great idea and good implementation from @visualheroes
Can you add this as a new feature to the existing codebase by integrate by PR it with some wiki instruction on how to use it ? thank you
@visualheroes Thanks it works like a charm.
Another Idea I have is, instead of based on how many people i'm following, but based off how many InstaPyFollowedUser from the followedpool, or we can call the pool as a buffer. we can say
if remaingUser > 100
unfollow
else:
dofollow
this way, we always keep a reasonaly amout of following regardless how many user you are following.
Most helpful comment
This works for me (you can replace "user" by your name for namesake):
Edit: i cleaned the code a bit as i do a different set of actions if the followers to unfollow are greater than 10. You can build your own loop from this. ;)