-
Notifications
You must be signed in to change notification settings - Fork 11
/
ff.py
43 lines (35 loc) · 1.16 KB
/
ff.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from TwitterAPI import TwitterAPI
import logging
import json
import time
"""
Fill in your keys before running. https://apps.twitter.com/
"""
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
ACCESS_TOKEN = ''
ACCESS_TOKEN_SECRET = ''
SCREEN_NAME = 'eiaine'
def main():
logging.basicConfig(level=logging.INFO)
bot = TwitterAPI(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
cursor = -1
count = 0
with open('data.csv', 'a+') as f:
f.write("close,date\n")
while True:
if not cursor:
break
fans_raw = bot.request('followers/list', {'screen_name': SCREEN_NAME, 'count': 200, 'cursor':cursor, 'skip_status':True, 'include_user_entities': False})
fans_clean = json.loads(fans_raw.response.text)
cursor = fans_clean['next_cursor']
logging.info(cursor)
fans = [f['created_at'] for f in fans_clean['users']]
with open('data.csv', 'a') as f:
for fans in fans_clean['users']:
f.write("%s,%s \n" % (fans['id'], fans['created_at']) )
count += 200
logging.info("count: %s" % count)
time.sleep(60)
if __name__ == "__main__":
main()