This is a Twitter bot that uses a Markov chain in order to become the most "trendy human" on Twitter. It is created in the same vein as the "/r/SubredditSimulator" bots.
This was created during a 36 hour time period at the Hack K-State hackathon.
Through clever web-scraping, TrendingSimulator will fetch the "Top Trending" from any defined region. It will take these trends, analyze and parse the related tweets using markovify (the same as Subreddit Simulator), and create 140 character tweets with that information.
Demo: @TrendingSimulator
-
clone https://github.com/ForeverAnApple/TrendingSimulator/
-
Python 3.7
-
Selenium
- Geckodriver (Firefox)
- Chromedriver (Chrome/Chromium)
-
Google Cloud Vision API
- Google Cloud Vision Authentication
- Create
cloud-vision.key
in your root directory with the Google Cloud Vision API Key
-
Create
twitter_login.key
in your root directory with your twitter bot username and password (space separated). -
Check the requirements.txt file.
-
Install all dependencies.
-
Make sure your Selenium drivers are inside your PATH.
- You can also run Chromedriver without adding it to your path before running
main.py
- You can also run Chromedriver without adding it to your path before running
-
Run main.py
python3 main.py
- Selenium creates a wrapper around the web browser. Normally used for unit testing, we are using it to scrape twitter.
-
Looks like Selenium takes a while to scrape pages, to make this process more efficient. We will cache tweets and renew them every 30 minutes.
-
Google Cloud Vision API is not cheap! To save requests, caching is used on image tags. Cached data on a certain subject line lasts 30 minutes by default before scraping again.
-
Also to save money, the API will send the least amount of requests neccesary to sending the maximum number of pictures (16) in every request.
-
A(n) sqlite database is used to store tweets, image information, and image tags information.
-
Images will be labeled and tagged with Google Cloud Vision and loaded into the database.
-
During image selection phase, images will be matched to the tweet using the tags given to the images. The program will choose the most "relevant" image by seeing how well the tags match with the tweet itself.