-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfollower.py
More file actions
54 lines (39 loc) · 1.27 KB
/
Copy pathfollower.py
File metadata and controls
54 lines (39 loc) · 1.27 KB
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
44
45
46
47
48
49
50
51
52
53
import tweepy
import conf
import time
import requests
auth = tweepy.OAuthHandler(conf.API_KEY, conf.API_SECRET)
auth.set_access_token(conf.ACCESS_TOKEN, conf.ACCESS_TOKEN_SECRET)
api = tweepy.API(auth)
# ========>> Follow Thee followers
# https://github.com/tweepy/tweepy/blob/master/docs/code_snippet.rst
# def limit_handled(cursor):
# while True:
# try:
# yield cursor.next()
# except tweepy.RateLimitError:
# time.sleep(15 * 60)
#
#
# i = 0
# for follower in limit_handled(tweepy.Cursor(api.followers).items()):
# follower.follow()
# # print(f"Follower {i} = {follower.name} ")
# i+=1
# print(f"Follower {i} = {follower.name} followed")
#
#
try:
user = 'mohapsat' # Me
u = api.get_user(user)
MY_ID = u.id_str
following = set(api.friends_ids(MY_ID)) # people am follwoing
followers = set(api.followers_ids(MY_ID)) # people who are following me
not_following = followers - following # people my bot needs to follow
# print(f"people my bot needs to follow: {not_following}")
for item in list(not_following)[:1]:
api.create_friendship(item)
time.sleep(2)
print(f"now following: {item}")
except tweepy.error.TweepError:
print("tweepy.error.TweepError ")