My flask API looks like this:
@app.route('/getCuentaReferencia', methods=['GET'])
def getFollowers():
x = set()
try:
for user in tweepy.Cursor(api.get_followers, screen_name=request.args.get('cuentaReferencia')).items(int(request.args.get('cantidadCuenta'))):
x.add(user._json['screen_name'])
except Exception as e:
print(e)
pass
with open(request.args.get("cuentaReferencia") ".json", "w") as f:
json.dump(list(x), f)
return jsonify({
"cuentaReferencia": request.args.get("cuentaReferencia") request.args.get("region") ".json",
})
From frontend I send the screen name of the account and the quantity of followers that I'm looking for:
const response = await fetch(
`http://localhost:5000/getCuentaReferencia?cuentaReferencia=${cuentaReferencia}&cantidadCuenta=${
cantidadCuenta ?? ""
}®ion=${region}`
);
But when the Twitter API reach the limit, after waiting the cooldown it didn't continue looking for followers and only returns a few ones (if I need to get 1000, it returns me 300 because in that number of followers reaches the limit) I need to get all the count of followers that I send from frontend, how can i fix this up?
CodePudding user response:
You can set the count
argument of get_followers()
to 200, its maximum (while default is only 20). That will allow you to get 3000 followers without reaching the rate limit.
You can read more about this argument in the Twitter documentation here.
If you want to get even more followers, you should probably use the Twitter API V2 instead.