in Bot1/hello_world/twitterRetweet.py [0:0]
def retweet(api, search, numberOfTweets):
for tweet in tweepy.Cursor(api.search, search).items(numberOfTweets):
try:
tweet_id = tweet.id
print(tweet_id)
if tweet.lang == "en":
print(tweet.body)
tweet.retweet()
print('Retweeted the tweet')
else:
print('no retweet')
except tweepy.TweepError as e:
print(e.reason)
except StopIteration:
break