FOLLOWER TWITTER in PYTHON
LIMITED ONLY 100-150 TWEETS @ HOURS
CODE :
# -------.PY---
import sys, csv, StringIO
import tweepy
def get_followers(api, screen_name):
followers_count = api.get_user(screen_name = screen_name).followers_count
cursor = tweepy.Cursor(api.followers, screen_name = screen_name)
followers = cursor.items()
followers_list = []
count = 1
for follower in followers:
_row = (
follower.screen_name,
unicode(follower.name),
unicode(follower.location),
str(follower.created_at),
str(follower.followers_count),
str(follower.friends_count),
str(follower.statuses_count),
str(follower.favourites_count),
str(follower.lang),
str(follower.verified),
unicode(follower.description),
)
row = [ _str.encode('utf8') for _str in _row ]
followers_list.append(row)
sys.stderr.write(str(count) + '/' + str(followers_count)+"\n")
count += 1
return followers_list
def main():
stringio = StringIO.StringIO()
writer = csv.writer(stringio)
csv_header = (
'screen_name',
'name',
'location',
'created_at',
'followers_count',
'friends_count',
'statuses_count',
'favourites_count',
'lang',
'verified',
'description',
)
writer.writerow(csv_header)
screen_name = 'XXXXXXXXXX - FILL SCREENNAME TWITTER'
api = tweepy.API()
writer.writerows(get_followers(api, screen_name))
sys.stdout.write(stringio.getvalue())
if __name__ == "__main__":
main()
No comments:
Post a Comment