Python Twitter Bot – How-To With Scripts

I’m going to show you how I created a twitter bot using Python. I wanted to create a twitter bot that I could run on my raspberry pi. I decided to combine the Bitcoin script that I was helped with in a previous post. The script queries the CoinDesk API for current the current Bitcoin price and last years bitcoin price and posts it to twitter every 24 hours.

First you need to create a new twitter account that you are going to use for the bot. To access the twitter API you will need to register a new app, you can use this link. After registering a new app you will need to update the “Application Type” under the permissions tab to “Read and Write”. Under the Keys and Access Tokens tab click “Generate Consumer Key and Secret” you will be provided with an Consumer Key, Consumer Secret, Access Token, and Access Token Secret. You will need this information for you script to login to the twitter API.

Next you need to install Tweepy on the device you will be running the script from. On my raspberry pi I simply typed  pip install tweepy

Tweepy installation instructions can be found on GitHub

Use the script below and fill in the Consumer Key, Consumer Secret, Access Token, and Access Token Secret that you generated earlier for your bot. You now have a twitterbot!

Follow my bot on twitter at @Evil_1T

As always I would like any input and feedback on what you guys think. All ideas welcome

My GitHub repository for this project – https://github.com/llamafarmer/twitterbot

Tweepy install – https://github.com/tweepy/tweepy

Twitter Bot – https://twitter.com/Evil_1T

Raspberry Pi 3 (The same one I’m using) – http://amzn.to/2gzPPlz

Advertisements
This entry was posted in Uncategorized and tagged , , , , . Bookmark the permalink.

One Response to Python Twitter Bot – How-To With Scripts

  1. This is great work! I have used tweepy before to pull data from twitter, but never created a bot. I hope you don’t mind using your code to create bot for myself 🙂 Not sure what kinda of bot i will create, but sounds exciting to work with.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s