30 lines
831 B
Python
Executable file
30 lines
831 B
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
import tools
|
|
import os, time, tweepy
|
|
|
|
def getFollowerIDs(two=tools.twObject()):
|
|
''' Returns 5,000 follower IDs at most '''
|
|
return two.api.followers_ids(screen_name=tools.user())
|
|
|
|
def getNamesByIDs(fids=getFollowerIDs(), two=tools.twObject()):
|
|
for page in tools.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)
|
|
|
|
def getOutFile(dirname="followers"):
|
|
getOutDir(dirname)
|
|
return os.path.join(dirname, str(int(time.time())) + ".txt")
|
|
|
|
def writeOutFile(outfile=getOutFile()):
|
|
with open(getOutFile(), 'a') as f:
|
|
for follower in getNamesByIDs(getFollowerIDs()):
|
|
f.write(follower + "\n")
|
|
|
|
if __name__ == "__main__":
|
|
writeOutFile()
|