Last active
March 21, 2022 14:50
-
-
Save dlmrr/72b0402a15101dc8d065184683272acc to your computer and use it in GitHub Desktop.
script to copy someone's twitter timeline
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 | |
# Authenticate to Twitter | |
auth = tweepy.OAuthHandler(consumer_token, consumer_secret) | |
auth.set_access_token(key, secret) | |
api = tweepy.API(auth) | |
try: | |
api.verify_credentials() | |
print("Authentication OK") | |
except: | |
print("Error during authentication") | |
api = tweepy.API(auth, wait_on_rate_limit=True,wait_on_rate_limit_notify=True) | |
def create_list(user): | |
followed_list = api.friends_ids(id=user) | |
lists_list = [followed_list[x:x+99] for x in range(0, len(followed_list), 99)] | |
dmc_list = api.create_list(name=user + "'s Timeline", mode="private", description="{}'s timeline".format(user)) | |
for users in lists_list: | |
try: | |
add = api.add_list_members(users, list_id=dmc_list.id) | |
print(add) | |
except Exception as e: print(e) | |
print("Enter a user's handle to generate a duplicate of its timeline") | |
user = input() | |
create_list(user) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment