A twitter bot to automatically gather quotes from the internet and save them in a database. The bot uses web scraping techniques and libraries to extract quotes from websites and then stores them in a database for future use.
The bot also has the capability to automatically tweet a quote at regular intervals using cron jobs. The bot uses Twitter API for authentication and posting tweets.
Visit - https://twitter.com/ko8bot to checkout the bot.
scrape.py
- Scrapes the goodreads website to scrape multiple pages of quotes and saves it in google sheet using requests, beatifulsoup and gspread API.
main.py
- Fetches single quote from sheets db and Initializes and Authenticates twitter account then tweets the quote using official twitter developer API.
.env
- Saves the secrets and API tokens.
- Clone the project on your local system using:
git clone https://github.com/adhirajpandey/Twitter-Quote-Bot
- Setup Virtual Environment using:
python -m venv venv
and activate it. - Install the dependencies:
pip install -r requirements.txt
- Enable the Google Drive API, create a service account and downloadd the json key file. Check this out for reference - here
- Create a Twitter account and register for developer account to get access to API.
- Copy the required token values in .env file in the cloned directory.
- Create a google sheet and name it
Twitter-Bot
and share it with that service account. - Scrape and Store the quotes using:
python scrape.py
- Test the tweet functionality using:
python main.py
- Deploy the main.py file with cron job using any cloud service provider to autmate the tweet process at set time interval.