-
-
Notifications
You must be signed in to change notification settings - Fork 314
/
Copy pathmain.py
37 lines (34 loc) · 939 Bytes
/
main.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
import tweepy
import time
apic= ""# add api_code
apisc="" # add api_secret_code
acc= ""#add account_code
acsc= ""# add acount_secret_code
cnt=open(r"bot.txt","r+")
counts=cnt.read()
count=int(counts)
auth = tweepy.OAuthHandler(apic,apisc)
auth.set_access_token(acc,acsc)
api=tweepy.API(auth,wait_on_rate_limit=True,wait_on_rate_limit_notify=True)
user=api.me()
print(user.screen_name)
search=input("Enter the keyword to be searched") # akss for the keyword here
nrtweets=500
count=0
for tweet in tweepy.Cursor(api.search,search).items(nrtweets):
try:
print("tweet-number",count,"retweeted")
count=count+1
tweet.retweet()
time.sleep(30)
ctr=str(count)
cnt.truncate()
cnt.write(ctr)
print("RETWEETED:",count)
except tweepy.TweepError as e:
print(e.reason)
except StopIteration:
break
ctr=str(count)
cnt.truncate()
cnt.write(ctr)