How to retweet tweets from specific user with python, tutorial

How to retweet all tweets from a specific user, not a search query? This was my challenge for today and find a simple solution that can retweet all tweets.







First, you need to create a Twitter app and install the Python Tweepy library. You should have your Consumer Key, Consumer Secret, Access Token, and Access Token Secret in hand before beginning this tutorial.
Now you can create
credentials.py file and paste your credentials from Twitter API site. 




Now we can start working on the script.I've added a try ... except block to our code, and have the console print out the reason for the error.This will help to avoid duplicated tweets and keep programme running if we will find errors. 


One more thing we should add is sleep() to ensure that these tweets don’t all go out at once. The function sleep() works with the time unit measure of seconds, so if we want an hour between tweets, we should write the function as sleep(3600) because there are 3,600 seconds in an hour.

No comments:

Post a Comment

Fork me on GitHub