-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwitbot.py
35 lines (26 loc) · 914 Bytes
/
twitbot.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
import tweepy
import time
auth = tweepy.OAuthHandler('bNJA2IaqEYidSoKIPIsN3lSnb', '71poMRm3uSqAImAMe3y4oQEopRMFoUeyB6lHdAogVuGZqCxATG')
auth.set_access_token('298552998-2only899kf4QmOgCEMHqvj78PA1faMWfxAXRrDfx', 'zcuy4AauGY19otHXQTKFqMTlVMZ9HnKWOSslUSklEMmrd')
api = tweepy.API(auth)
user = api.me()
def limit_handler(cursor):
try:
while True:
yield cursor.next()
except tweepy.RateLimitError:
time.sleep(300)
# for follower in limit_handler(tweepy.Cursor(api.followers).items()):
# if follower.name == "":
# follower.follow()
# break
search_string = "pisi"
number_of_tweets = 5
for tweet in tweepy.Cursor(api.search, search_string).items(number_of_tweets):
try:
tweet.favorite()
print("liked")
except tweepy.TweepError as e:
print(e.reason)
except StopIteration:
break