def GetFollowers(self,key_,**kwargs): params=None for key in ["screen_name","user_id"]: if key in kwargs.keys(): params={key:kwargs.get(key,None)} break url="https://api.twitter.com/1.1/followers/ids.json" List=[] while len(List)==0 or timeline["next_cursor"]!=0: req = self.twitter.get(url,params=params) timeline = json.loads(req.text) self.limit = req.headers['x-rate-limit-remaining'] if 'x-rate-limit-remaining' in req.headers else 0 self.reset = req.headers['X-Rate-Limit-Reset'] if 'x-rate-limit-remaining' in req.headers else 0 if int(self.limit)==0: np.savetxt(self.path+params["screen_name"]+".csv",List,delimiter=",") print("Stored",params["screen_name"],len(List)) self.WaitUntilReset() self.twitter=OAuth1Session(CONSUMER_KEY,CONSUMER_SECRET,ACCESS_TOKEN, ACCESS_TOKEN_SECRET) continue if len(timeline["ids"])==0: return List List+=timeline["ids"] params["cursor"]=timeline["next_cursor_str"] return List