![]() |
VOOZH | about |
Twitter is an American microblogging and social networking service on which users post and interact with messages known as "tweets". In this article we will make a Twitter Bot using Python.
Python as well as Javascript can be used to develop an automatic Twitter bot that can do many tasks by its own such as:
For all this we will need a Python library called Tweepy for accessing the Twitter API. We can install tweepy in three ways:
1. Using pip command
$ pip install tweepy
2. Clone the GitHub repository of tweepy
$ git clone https://github.com/tweepy/tweepy $ cd tweepy $ pip install
3. Cloning the repository directly
$ pip install git+https://github.com/tweepy/tweepy
Make a file twitterbot_retweet.py and paste the following code.
Now make another file to specify what should your bot do. Name it config.py
Edit the #hashtag according to your choice and the like or follow option to either True or False.
Next make a file credentials.py and paste your access tokens carefully in between the single quotes ' '.
Run the twitterbot_retweet.py file from your Command Prompt/Terminal with this command.
$ python twitterbot_retweet.py
And it works!!