A stupid project inspired by a tweet.
Every hour, scrape FiveThirtyEight (using puppeteer) to get Trump's approval rating. On request, return a random movie from a DB (er, JSON file) with the same rating on Rotten Tomatoes as the approval rating.
The DB was created by scraping 150 pages of the TMDb /discover endpoint, pulling in additional information (Rotten Tomatoes score and poster url) from OMDB, then searching Rotten Tomatoes (literally by scraping https://www.rottentomatoes.com/search/?search=MOVIE_TITLE, again with puppeteer) and parsing the results to find the Rotten Tomatoes url. I had to introduce a delay (here) because I think somebody found out what I was doing and started throttling my requests.
[Mostly for my own reference, I have no idea why you would want to do this.]
Rotten Trumpatoes is set up to be deployed via dokku (which I love very much). Puppeteer relies on dependencies that aren't in the default docker container so you'll need to install the dokku-apt plugin (which automatically pulls from apt-packages). I stole this approach from dokku-puppeteer-example.
I use dotenv, which relies on a
.env at the root of the project. Because this file isn't version controlled, you'll have to set the environment variables on dokku as well (like so). For local development, add a
.env with the following: