Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #BY AERO
- import json
- import tweepy
- from time import sleep
- config = dict()
- with open('config.json') as CONFIG:
- config = json.load(CONFIG)
- #add your twitter keys here
- query = (
- """#cybersecurity OR #Cybersecurity #osint OR #OSINT OR #threatanalytics OR #InfoSec OR #infosec"""
- )
- class constant:
- def __init__(self, query):
- consumer = config['consumer']
- consumer_s = config['consumer_s']
- token = config['token']
- token_s = config['token_s']
- # Authenticate to Twitter
- self.auth = tweepy.OAuthHandler(consumer, consumer_s)
- self.auth.set_access_token(token, token_s)
- self.api = tweepy.API(self.auth)
- self.query = query
- def retweetQuery(self):
- for tweet in tweepy.Cursor(self.api.search, q=(self.query + ' -filter:retweets'), lang='en').items(5):
- try:
- print('\nTweet by: @' + tweet.user.screen_name)
- tweet.retweet()
- print('Retweeted the tweet')
- sleep(1)
- except tweepy.TweepError as e:
- print(e.reason)
- except StopIteration:
- break
- c = 0
- for tweet in tweepy.Cursor(self.api.search, q=(self.query + ' -filter:retweets'),lang='en').items(10):
- try:
- print('\nTweet by: @' + tweet.user.screen_name)
- tweet.favorite()
- print('Like the tweet')
- sleep(5)
- except tweepy.TweepError as e:
- print(e.reason)
- except StopIteration:
- break
- c += 1
- if c == 15: break
- def startBot(self):
- while True:
- self.retweetQuery()
- sleep(1600)
- constant(query).startBot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement