Comments (10)
That's interesting! I never looked at this except when I was far below 5,000 followers. Now I have to wonder how many people I've unfollowed on accident...
I've confirmed that these calls do indeed only return 5,000 users at a time. Filed this as a bug.
from twitterfollowbot.
I've started hacking at the code a bit and found a solution, but unfortunately it doesn't seem to scale. I basically work through the cursors to build up a list of all of the user's followers and who they're following. In my case, that's ~40k IDs in both sets, which is about 16 API calls just to populate these lists. As you can imagine, I hit the Twitter API rate limit pretty quick by testing that. And I didn't even do any following/favoriting/etc.
def auto_unfollow_nonfollowers():
"""
Unfollows everyone who hasn't followed you back
"""
# create a list of all users that the user is following and followed by
# necessary to use cursors if the user has >5,000 followers or following
followers_status = t.followers.ids(screen_name=TWITTER_HANDLE)
followers = set(followers_status["ids"])
next_cursor = followers_status["next_cursor"]
while next_cursor != 0:
followers_status = t.followers.ids(screen_name=TWITTER_HANDLE, cursor=next_cursor)
followers.update(followers_status["ids"])
next_cursor = followers_status["next_cursor"]
following_status = t.friends.ids(screen_name=TWITTER_HANDLE)
following = set(following_status["ids"])
next_cursor = following_status["next_cursor"]
while next_cursor != 0:
following_status = t.friends.ids(screen_name=TWITTER_HANDLE, cursor=next_cursor)
following.update(following_status["ids"])
next_cursor = following_status["next_cursor"]
# ... rest of the code goes here
Perhaps a more scalable solution is to store the IDs locally and have a one-time "setup" function that users have to call to populate these lists. But that won't be a perfect solution because any follow/unfollow not done through the bot won't be recorded in the list. Furthermore, if anyone unfollows them after the setup, that also won't be reflected in the local list.
In the meantime, I advise against using the auto unfollow functionality if you have over 5,000 followers.
from twitterfollowbot.
I do it on the regular honestly. twitter doesnt limit me and i have accounts with 40k followers.
from twitterfollowbot.
Hi Randy,
I see that there is a 15 API calls per 15 minutes window limit. If you delay each API call that populates the list of people that don't follow you back, would twitter still block you?
So for example, the function would grab all the cursors/pages until it hits the API limit, wait for 15 minutes, then continue the process.
Another option would be use multiple Twitter Apps/API Keys and switch among them, but I don't think this is a good idea.
What do you think?
from twitterfollowbot.
Randy,
Please take a look on this:
bear/python-twitter#71
More precisely, the last comment. I will play with that tonight and see what I can get.
from twitterfollowbot.
@vmunich, please let me know if you have any luck with that method! It seems promising.
from twitterfollowbot.
Any luck with that method, @vmunich?
from twitterfollowbot.
Sorry to jump in on this thread! Did anyone find a solution for this? @vmunich @rhiever? Thanks for your time and help!
from twitterfollowbot.
Still a standing issue. Haven't had time to dedicate to this bot.
from twitterfollowbot.
Finally got around to fixing this issue. Cursors ended up being the key to fixing it - now the bot can properly look up all of an accounts follows/followers. However, due to API rate limits, follows/followers now have to be cached locally. I recommend running the new sync_follows()
method daily to ensure that the bot is working on a relatively up-to-date cache.
from twitterfollowbot.
Related Issues (20)
- Need help with installation please HOT 1
- auto_unfollow_nonfollowers() crashes for certain suspended user HOT 4
- Why my already-followed.txt is empty HOT 1
- twitterfollowbot 2.0.2 requires twitter==1.17.0, which is not installed. HOT 1
- Erreur de Syntaxe detectées dans les clés API
- probleme lors del'execution du programme python
- How to make the bot auto retweet the latest tweet? HOT 1
- Unfollow only X people that don't follow back?
- FYI - API wrapper methods out-dated; Project non-functional HOT 2
- Hello help me this problem not starting tweet bot
- dear author
- Automatically add users tweeting about something to one of your list
- Help with setting up a Twitter bot HOT 1
- a
- Can't run the bot HOT 2
- i am having this problem with irclib
- TwitterFollowBot
- T
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from twitterfollowbot.