Move follower functions to twitools
Create tables for storing followers and following in setup.py
This commit is contained in:
parent
6ffa8e052d
commit
b39b708270
2 changed files with 10 additions and 11 deletions
|
@ -3,16 +3,6 @@
|
|||
import twitools, setuptools
|
||||
import os, time, tweepy
|
||||
|
||||
def getFollowerIDs(two=twitools.twObject()):
|
||||
''' Returns 5,000 follower IDs at most '''
|
||||
return two.api.followers_ids(screen_name=twitools.twObject().whoami())
|
||||
|
||||
def getNamesByIDs(fids=getFollowerIDs(), two=twitools.twObject()):
|
||||
for page in setuptools.paginate(fids, 100):
|
||||
followers = two.api.lookup_users(user_ids=page)
|
||||
for follower in followers:
|
||||
yield follower.screen_name
|
||||
|
||||
def getOutDir(dirname="followers"):
|
||||
if not os.path.isdir(dirname):
|
||||
os.mkdir(dirname)
|
||||
|
@ -23,7 +13,7 @@ def getOutFile(dirname="followers"):
|
|||
|
||||
def writeOutFile(outfile=getOutFile()):
|
||||
with open(getOutFile(), 'a') as f:
|
||||
for follower in getNamesByIDs(getFollowerIDs()):
|
||||
for follower in twitools.getNamesByIDs(twitools.getFollowerIDs()):
|
||||
f.write(follower + "\n")
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -18,3 +18,12 @@ class twObject:
|
|||
def whoami(self):
|
||||
return self.auth.get_username()
|
||||
|
||||
def getFollowerIDs(two=twObject()):
|
||||
''' Returns 5,000 follower IDs at most '''
|
||||
return two.api.followers_ids(screen_name=twObject().whoami())
|
||||
|
||||
def getNamesByIDs(fids=getFollowerIDs(), two=twObject()):
|
||||
for page in setuptools.paginate(fids, 100):
|
||||
followers = two.api.lookup_users(user_ids=page)
|
||||
for follower in followers:
|
||||
yield follower.screen_name
|
||||
|
|
Loading…
Reference in a new issue