Programming An Auto Tweeting Bot Using Tweepy and Beautiful Soup 4

@lee-rowe
3 min readJan 28, 2022
Photo by Alex Knight on Unsplash

I want to start this blog off by saying this was not the type of bot I actually indented to create when I first started this project, but since it was just for fun I decided to roll with it and ended up creating something completely different than I had originally planned on. Because of this, this will probably be the first edition of my Twitter bots. Besides that let’s get started covering all of what I did to get this thing working.

First things first, I started by scraping goodreads.com. Specifically the quotes section of their website, I did this to obtain a list on famous quotes essentially that I could then use to tweet along with a picture. This was a quite an easy step thanks to Beautiful Soup 4, I essentially just checked through this link https://www.goodreads.com/quotes/tag/{tag} and would then be able to search through any of goodread’s pages of quotes just by passing in any variable that also exists on their site. I next set up a function that would run my scraper and collect all the data into a json file. I will provide an example of my collect_quotes.py file below in a cell.

--

--