-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelloTweepy.py
More file actions
37 lines (29 loc) · 897 Bytes
/
helloTweepy.py
File metadata and controls
37 lines (29 loc) · 897 Bytes
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
import tweepy
import time
import os
import configparser
import random
config_file = dir_path = os.path.dirname(os.path.realpath(__file__)) + "\\tweepy_config.ini"
config = configparser.ConfigParser()
config.read(config_file)
tokens = config._sections['tokens']
#authentication
auth = tweepy.OAuthHandler(tokens['pk'], tokens['sk']
)
auth.set_access_token(tokens['at'], tokens['ats']
)
api = tweepy.API(auth, wait_on_rate_limit = True)
def limit_handled(cursor):
while True:
try:
yield cursor.next()
except tweepy.RateLimitError:
time.sleep(15 * 60)
user = api.get_user('jackybetch')
friends = api.friends_ids('jackybetch')
for friend in friends:
temp = api.friends_ids(friend)
if len(temp)<400:
if user.id not in temp:
print(api.get_user(friend).screen_name, 'doesnt follow back')
public_tweets = api.home_timeline()