Created
November 26, 2016 18:02
-
-
Save ziggy42/40ee995dc400eb01fdebec4e6e0b8e39 to your computer and use it in GitHub Desktop.
Send random tweets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import tweepy | |
| from time import sleep | |
| from random import choice | |
| from string import ascii_uppercase | |
| from sys import argv | |
| CONSUMER_KEY = "" | |
| CONSUMER_SECRET = "" | |
| ACCESS_TOKEN = "" | |
| ACCESS_TOKEN_SECRET = "" | |
| def get_random_string(): | |
| return ''.join(choice(ascii_uppercase) for i in range(12)) | |
| def send_random_tweet(api): | |
| random_string = get_random_string() | |
| print("Sending " + random_string) | |
| api.update_status(random_string) | |
| if __name__ == "__main__": | |
| auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) | |
| auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET) | |
| api = tweepy.API(auth) | |
| for i in range(int(argv[1])): | |
| send_random_tweet(api) | |
| sleep(2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment