Skip to content
This repository was archived by the owner on Nov 30, 2022. It is now read-only.

Commit 36d19dd

Browse files
committed
Twitter Automation.py Added
1 parent 8a9cfca commit 36d19dd

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
3+
#Importing Library
4+
import tweepy
5+
import time
6+
7+
#Twitter Authentication APIs
8+
CONSUMER_KEY = '<enter-your-consumer-key>'
9+
CONSUMER_SECRET = '<enter-your-consumer-secret-key>'
10+
ACCESS_KEY = '<enter-your-access-key>'
11+
ACCESS_SECRET = '<enter-your-access-secret-key>'
12+
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
13+
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
14+
15+
#Likes & Retweeting
16+
api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True)
17+
user = api.me()
18+
search = '#india'
19+
numTweet = 500
20+
for tweet in tweepy.Cursor(api.search, search).items(numTweet):
21+
try:
22+
print('Tweet Liked') #Like
23+
tweet.favorite()
24+
print("Retweet done") #Retweet
25+
tweet.retweet()
26+
time.sleep(10)
27+
except tweepy.TweepError as e:
28+
print(e.reason)
29+
except StopIteration:
30+
break
31+
32+
##Press 'i' to stop iteration in jupyter notebook

0 commit comments

Comments
 (0)